From d6f217c1b956517ff36bf192f273940473bc6d5e Mon Sep 17 00:00:00 2001 From: Kristofer Koishigawa Date: Fri, 13 Apr 2018 23:15:40 +0900 Subject: [PATCH] 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: None --- seed/challengeTitles.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/seed/challengeTitles.js b/seed/challengeTitles.js index c7edd45481..a43e144972 100644 --- a/seed/challengeTitles.js +++ b/seed/challengeTitles.js @@ -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.