Skip to content

Commit 6f747e5

Browse files
committed
update module 1 tests to still pass when certain conditions are eventually met in module 2
1 parent eb2cc00 commit 6f747e5

File tree

3 files changed

+39
-0
lines changed

3 files changed

+39
-0
lines changed

src/__tests__/module1/quiz-component-displays-instruction-text.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ try {
1313
quizComponentExists = false;
1414
}
1515

16+
let quizQuestionComponentExists = false;
17+
let QuizQuestion;
18+
try {
19+
QuizQuestion = require('../../QuizQuestion.js').default;
20+
quizQuestionComponentExists = true;
21+
} catch (e) {
22+
quizQuestionComponentExists = false;
23+
}
24+
1625
let fs = require('fs');
1726
let quizData = require('../../quiz_data.json')
1827

@@ -29,6 +38,10 @@ describe('Quiz Component', () => {
2938

3039
if (quiz.find('.QuizQuestion').length > 0) {
3140
assert(quiz.find('.QuizQuestion').text() == quizData.quiz_questions[0].instruction_text, "The div with a className of `QuizQuestion` isn't displaying the correct instruction text.")
41+
} else if (quizQuestionComponentExists) {
42+
if (quiz.containsMatchingElement(<QuizQuestion />)) {
43+
// this block will run after @quiz-question-component-has-render-method in module 2
44+
}
3245
} else {
3346
assert(false, "There is not a div with a className of QuizQuestion yet.")
3447
}

src/__tests__/module1/quiz-component-has-quiz-question-div.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ try {
1313
quizComponentExists = false;
1414
}
1515

16+
let quizQuestionComponentExists = false;
17+
let QuizQuestion;
18+
try {
19+
QuizQuestion = require('../../QuizQuestion.js').default;
20+
quizQuestionComponentExists = true;
21+
} catch (e) {
22+
quizQuestionComponentExists = false;
23+
}
24+
1625
let fs = require('fs');
1726
let quizData = require('../../quiz_data.json')
1827

@@ -40,6 +49,10 @@ describe('Quiz Component', () => {
4049
} else if (quiz.containsMatchingElement(<div>Quiz</div>)) {
4150
// this block will run until @quiz-component-has-quiz-question-div
4251
assert(false, "The Quiz component isn't rendering a single div with the class `QuizQuestion`.")
52+
} else if (quizQuestionComponentExists) {
53+
if (quiz.containsMatchingElement(<QuizQuestion />)) {
54+
// this block will run after @quiz-question-component-has-render-method in module 2
55+
}
4356
} else {
4457
assert(false, "The Quiz component isn't rendering a single div with the class `QuizQuestion`.")
4558
}

src/__tests__/module1/quiz-component-has-render-method.test.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,15 @@ try {
1313
quizComponentExists = false;
1414
}
1515

16+
let quizQuestionComponentExists = false;
17+
let QuizQuestion;
18+
try {
19+
QuizQuestion = require('../../QuizQuestion.js').default;
20+
quizQuestionComponentExists = true;
21+
} catch (e) {
22+
quizQuestionComponentExists = false;
23+
}
24+
1625
let fs = require('fs');
1726
let quizData = require('../../quiz_data.json')
1827

@@ -36,6 +45,10 @@ describe('Quiz Component', () => {
3645
assert(el.props.children == quizData.quiz_questions[0].instruction_text)
3746
}
3847
}
48+
} else if (quizQuestionComponentExists) {
49+
if (quiz.containsMatchingElement(<QuizQuestion />)) {
50+
// this block will run after @quiz-question-component-has-render-method in module 2
51+
}
3952
} else {
4053
// this block will run until @quiz-component-has-quiz-question-div
4154
assert(quiz.containsMatchingElement(<div>Quiz</div>), "The Quiz component isn't rendering a single div with the text `Quiz`.")

0 commit comments

Comments
 (0)