Skip to content

Commit 00306d2

Browse files
No ref/fix type issues (#409)
* fix tests * fix tests * remove only * readd test * Update spec/src/modules/quizzes.js --------- Co-authored-by: Enes Kutay SEZEN <eneskutaysezen@gmail.com>
1 parent 9d53470 commit 00306d2

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

spec/src/modules/quizzes.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => {
6262
expect(res).to.have.property('quiz_version_id').to.be.an('string');
6363
expect(res).to.have.property('questions').to.be.an('array');
6464
expect(res.questions[0].id).to.equal(1);
65-
expect(res.total_questions).to.equal(1);
65+
expect(res.total_questions).to.equal(4);
6666
expect(fetchSpy).to.have.been.called;
6767
expect(requestedUrlParams).to.have.property('key');
6868
expect(requestedUrlParams).to.have.property('i');
@@ -103,7 +103,7 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => {
103103

104104
expect(res).to.have.property('questions').to.be.an('array');
105105
expect(res).to.have.property('quiz_version_id').to.be.an('string').to.equal(quizVersionId);
106-
expect(res.total_questions).to.equal(1);
106+
expect(res.total_questions).to.equal(4);
107107
expect(fetchSpy).to.have.been.called;
108108
expect(requestedUrlParams).to.have.property('quiz_version_id').to.equal(quizVersionId);
109109
});
@@ -145,6 +145,18 @@ describe(`ConstructorIO - Quizzes${bundledDescriptionSuffix}`, () => {
145145

146146
return expect(quizzes.getQuizAllQuestions(validQuizId, { quizVersionId: 'foo' })).to.eventually.be.rejected;
147147
});
148+
149+
it('Should return 400 when quiz has jump logic', () => {
150+
const { quizzes } = new ConstructorIO({
151+
apiKey: quizApiKey,
152+
fetch: fetchSpy,
153+
});
154+
155+
return expect(quizzes.getQuizAllQuestions('test-quiz-2')).to.eventually.be.rejected.then((err) => {
156+
expect(err.status).to.equal(400);
157+
expect(err.message).to.equal('The requested quiz does not support question retrieval.');
158+
});
159+
});
148160
});
149161

150162
describe('getQuizNextQuestion', () => {

src/types/tests/quizzes.test-d.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ expectAssignable<NextQuestionResponse>({
88
description: 'Sample description',
99
type: 'multiple',
1010
cta_text: 'Next',
11+
is_skippable: false,
1112
images: {
1213
primary_url: 'https://example.com/image',
1314
primary_alt: 'Example image',
@@ -44,6 +45,7 @@ expectAssignable<NextQuestionResponse>({
4445
id: 1,
4546
title: 'Sample open text question',
4647
description: 'Sample description',
48+
is_skippable: false,
4749
type: 'open',
4850
cta_text: 'Next',
4951
images: {
@@ -299,4 +301,5 @@ expectAssignable<QuizResultsConfigResponse>({
299301
},
300302
quiz_version_id: '6bfaa6d5-7272-466b-acd9-4bcf322a2f1e',
301303
quiz_id: 'test-quiz',
304+
metadata: null,
302305
});

0 commit comments

Comments
 (0)