forked from wikimedia-gadgets/twinkle
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tag: add tests for checkIncompatible() (wikimedia-gadgets#2120)
* tag: add tests for checkIncompatible() Writing automated tests for this gives me more confidence that I didn't make a mistake in PR wikimedia-gadgets#2103 * expand docblock * rename variable, extract variable
- Loading branch information
1 parent
e40b960
commit bc79c32
Showing
3 changed files
with
78 additions
and
22 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
describe('modules/twinkletag', () => { | ||
describe('checkIncompatible', () => { | ||
test('no conflicts', () => { | ||
const incompatibleTags = ['Bad GIF', 'Bad JPEG', 'Bad SVG', 'Bad format']; | ||
const tagsToCheck = ['Better source requested']; | ||
const expected = undefined; | ||
expect(Twinkle.tag.checkIncompatible(incompatibleTags, tagsToCheck)).toBe(expected); | ||
}); | ||
|
||
test('incompatibleTags, tagsToCheck in alphabetical order', () => { | ||
const incompatibleTags = ['Bad GIF', 'Bad JPEG', 'Bad SVG', 'Bad format']; | ||
const tagsToCheck = ['Bad GIF', 'Bad JPEG']; | ||
const expected = true; | ||
expect(Twinkle.tag.checkIncompatible(incompatibleTags, tagsToCheck)).toBe(expected); | ||
}); | ||
|
||
test('incompatibleTags, tagsToCheck not in alphabetical order', () => { | ||
const incompatibleTags = ['Bad GIF', 'Bad JPEG', 'Bad SVG', 'Bad format']; | ||
const tagsToCheck = ['Bad JPEG', 'Bad GIF']; | ||
const expected = true; | ||
expect(Twinkle.tag.checkIncompatible(incompatibleTags, tagsToCheck)).toBe(expected); | ||
}); | ||
|
||
test('conflicts mixed with non-conflicts', () => { | ||
const incompatibleTags = ['Bad GIF', 'Bad JPEG', 'Bad SVG', 'Bad format']; | ||
const tagsToCheck = ['Better source requested', 'Bad GIF', 'Maybe free media', 'Bad JPEG', 'Copy to Commons']; | ||
const expected = true; | ||
expect(Twinkle.tag.checkIncompatible(incompatibleTags, tagsToCheck)).toBe(expected); | ||
}); | ||
|
||
test('extra param, no conflicts', () => { | ||
const incompatibleTags = ['Merge', 'Merge from', 'Merge to']; | ||
const tagsToCheck = ['One source']; | ||
const extraMessage = 'If several merges are required, use {{Merge}} and separate the article names with pipes (although in this case Twinkle cannot tag the other articles automatically).'; | ||
const expected = undefined; | ||
expect(Twinkle.tag.checkIncompatible(incompatibleTags, tagsToCheck, extraMessage)).toBe(expected); | ||
}); | ||
|
||
test('extra param, conflicts', () => { | ||
const incompatibleTags = ['Merge', 'Merge from', 'Merge to']; | ||
const tagsToCheck = ['Merge from', 'Merge to']; | ||
const extraMessage = 'If several merges are required, use {{Merge}} and separate the article names with pipes (although in this case Twinkle cannot tag the other articles automatically).'; | ||
const expected = true; | ||
expect(Twinkle.tag.checkIncompatible(incompatibleTags, tagsToCheck, extraMessage)).toBe(expected); | ||
}); | ||
}); | ||
}); |