-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add some jest coverage for recent regressions
Bug: T340112 Change-Id: I00a5a5f01c99c7c6039dacccd793d7e069ea230d
- Loading branch information
Showing
10 changed files
with
141 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
const defaultTagsOptions = require( './ext.pageTriage.defaultTagsOptions.js' ); | ||
const defaultDeletionTagsOptions = require( './ext.pageTriage.defaultTagsOptions/ext.pageTriage.defaultDeletionTagsOptions.js' ); | ||
|
||
module.exports = Object.assign( {}, defaultTagsOptions, defaultDeletionTagsOptions ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"@doc": "Virtual JSON. This code is only used in tests.", | ||
"TalkPageNoteTemplate": { | ||
"Tags": "Taggednote-NPF" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
const { Article } = require( 'ext.pageTriage.util' ); | ||
let DeleteToolView; | ||
|
||
describe( 'DeleteToolView', () => { | ||
beforeEach( () => { | ||
mw.config.get = jest.fn( ( key ) => { | ||
switch ( key ) { | ||
case 'wgPageName': | ||
return 'PageName'; | ||
default: | ||
return null; | ||
} | ||
} ); | ||
// needs to be loaded after mw.config.get has been defined to avoid fatal. | ||
DeleteToolView = require( '../../modules/ext.pageTriage.views.toolbar/delete.js' ); | ||
} ); | ||
|
||
test( 'notifyUser', () => { | ||
const eventBus = _.extend( {}, Backbone.Events ); | ||
const model = new Article( { | ||
eventBus, | ||
pageId: 5, | ||
includeHistory: true | ||
} ); | ||
const toolbar = new DeleteToolView( { eventBus, model } ); | ||
toolbar.selectedTag.tagKey = { | ||
usesSubpages: false | ||
}; | ||
|
||
const msg = toolbar.notifyUser( { | ||
tagCount: 1, | ||
tagKey: 'tagKey' | ||
} ); | ||
|
||
return msg.then( function () { | ||
expect( true ).toBe( true ); | ||
} ); | ||
} ); | ||
} ); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
const { Article } = require( 'ext.pageTriage.util' ); | ||
const TagToolView = require( '../../modules/ext.pageTriage.views.toolbar/tags.js' ); | ||
|
||
describe( 'TagToolView', () => { | ||
beforeEach( () => { | ||
mw.config.get = jest.fn( ( key ) => { | ||
switch ( key ) { | ||
case 'wgPageName': | ||
return 'PageName'; | ||
default: | ||
return null; | ||
} | ||
} ); | ||
} ); | ||
|
||
test( 'talkPageNote', () => { | ||
const actionQueue = { | ||
runAndRefresh: jest.fn() | ||
}; | ||
mw.pageTriage = { actionQueue }; | ||
const eventBus = _.extend( {}, Backbone.Events ); | ||
const model = new Article( { | ||
eventBus, | ||
pageId: 5, | ||
includeHistory: true | ||
} ); | ||
const toolbar = new TagToolView( { eventBus, model } ); | ||
return toolbar.talkPageNote( 'foo' ).then( () => { | ||
expect( actionQueue.runAndRefresh ).toBeCalled(); | ||
} ); | ||
} ); | ||
} ); |