fix(seed): Simplify Unique Titles Test (#17056)
Originally the test would check for the index of a title in an array of unique challenge titles. However, the index of the title within the array isn't important for this test, so I simplified the code using @Bouncey's suggestion in PR #17035. Also changed grammar for the error that's thrown when a challenge title isn't a valid string. BREAKING CHANGE: Nonepull/17059/head
parent
bcd31aa499
commit
d6f217c1b9
|
@ -6,13 +6,13 @@ class ChallengeTitles {
|
|||
}
|
||||
check(title) {
|
||||
if (typeof title !== 'string') {
|
||||
throw new Error(`Expected a valid string for ${title}, got ${typeof title}`);
|
||||
throw new Error(`Expected a valid string for ${title}, but got a(n) ${typeof title}`);
|
||||
} else if (title.length === 0) {
|
||||
throw new Error(`Expected a title length greater than 0`);
|
||||
}
|
||||
const titleToCheck = title.toLowerCase().replace(/\s+/g, '');
|
||||
const titleIndex = _.findIndex(this.knownTitles, existing => titleToCheck === existing);
|
||||
if (titleIndex !== -1) {
|
||||
const isKnown = this.knownTitles.includes(titleToCheck);
|
||||
if (isKnown) {
|
||||
throw new Error(`
|
||||
All challenges must have a unique title.
|
||||
|
||||
|
|
Loading…
Reference in New Issue