From 869b4f479ecc15c1828b46c2d8b2550e0b92760b Mon Sep 17 00:00:00 2001 From: Kristofer Koishigawa Date: Mon, 9 Dec 2019 19:36:32 +0900 Subject: [PATCH] fix(client): modified test suite to not throw errors (#37894) modified challenge test suite so it does not throw an error if two steps for the project based curriculum have the same title --- curriculum/test/utils/challengeTitles.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/curriculum/test/utils/challengeTitles.js b/curriculum/test/utils/challengeTitles.js index c083dc6678..b14d5fdd99 100644 --- a/curriculum/test/utils/challengeTitles.js +++ b/curriculum/test/utils/challengeTitles.js @@ -2,7 +2,7 @@ class ChallengeTitles { constructor() { this.knownTitles = []; } - check(title) { + check(title, pathAndTitle) { if (typeof title !== 'string') { throw new Error( `Expected a valid string for ${title}, but got a(n) ${typeof title}` @@ -12,15 +12,19 @@ class ChallengeTitles { if (titleToCheck.length === 0) { throw new Error('Expected a title length greater than 0'); } - const isKnown = this.knownTitles.includes(titleToCheck); + const isProjectCurriculumChallenge = title.match(/^Part\s*\d+/); + const titleToAdd = isProjectCurriculumChallenge + ? pathAndTitle + : titleToCheck; + const isKnown = this.knownTitles.includes(titleToAdd); if (isKnown) { throw new Error(` - All challenges must have a unique title. + All current curriculum challenges must have a unique title. - The title ${title} is already assigned + The title ${title} (at ${pathAndTitle}) is already assigned `); } - this.knownTitles = [...this.knownTitles, titleToCheck]; + this.knownTitles = [...this.knownTitles, titleToAdd]; } }