Skip to content

Commit 9e7eb20

Browse files
authored
Merge pull request #40 from luis-lab-prs/master
Fix bug #38 - improve tests for shuffle functionality
2 parents f23428c + 7d6abdc commit 9e7eb20

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

tests/question.spec.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -80,16 +80,16 @@ describe("Question", () => {
8080

8181
it("should shuffle the items in the 'choices' array", () => {
8282
// Array with the question choices to be used in the test and passed to the Quiz constructor
83-
const testChoices = ["choice1", "choice2", "choice3", "choice4", "choice5"];
83+
const testChoices = ["choice1", "choice2", "choice3", "choice4", "choice5", "choice6", "choice7"];
8484

8585
// Instantiate a new Question object with the test choices array
8686
const question = new Question("test", testChoices, "test");
8787
// Call the shuffleChoices() method on the Question object
8888
question.shuffleChoices();
8989

9090
// Check that the 'choices' property of the Question object is not equal to the test choices array (i.e. it has been changed/shuffled)
91-
expect(question.choices).not.toEqual(["choice1", "choice2", "choice3", "choice4", "choice5"]);
92-
expect(question.choices.length).toEqual(5);
91+
expect(question.choices).not.toEqual(["choice1", "choice2", "choice3", "choice4", "choice5", "choice6", "choice7"]);
92+
expect(question.choices.length).toEqual(testChoices.length);
9393
});
9494
});
9595
});

tests/quiz.spec.js

+4-4
Original file line numberDiff line numberDiff line change
@@ -127,15 +127,15 @@ describe("Quiz", () => {
127127
});
128128

129129
it("should shuffle the items in the 'questions' array", () => {
130-
// Array with questions to be used in the test and passed to the Quiz constructor
131-
const testQuestions = ["question1", "question2", "question3"];
130+
// Array with questions to be used in the test and passed to the Quiz constructor
131+
const testQuestions = ["question1", "question2", "question3", "question4", "question5", "question6", "question7"];
132132
// Instantiate a new Quiz object with the test questions
133133
const quiz = new Quiz(testQuestions, 60, 60);
134134
// Call the shuffleQuestions() method to shuffle the questions array in the quiz
135135
quiz.shuffleQuestions();
136136
// Check if the questions array is not equal to the original array (it has been changed/shuffled)
137-
expect(quiz.questions).not.toEqual(["question1", "question2", "question3"]);
138-
expect(quiz.questions.length).toEqual(3);
137+
expect(quiz.questions).not.toEqual(["question1", "question2", "question3", "question4", "question5", "question6", "question7"]);
138+
expect(quiz.questions.length).toEqual(testQuestions.length);
139139
});
140140
});
141141

0 commit comments

Comments
 (0)