@@ -12,6 +12,11 @@ import { shallowMount } from '@vue/test-utils';
12
12
import ContentNode from 'docc-render/components/ContentNode.vue' ;
13
13
import Quiz from 'docc-render/components/Tutorial/Assessments/Quiz.vue' ;
14
14
15
+ const i18nStub = {
16
+ name : 'i18n' ,
17
+ template : '<span>Answer is <slot name="result"/></span>' ,
18
+ } ;
19
+
15
20
const textContent = str => ( [ {
16
21
type : 'text' ,
17
22
text : str ,
@@ -105,7 +110,10 @@ describe('Quiz', () => {
105
110
106
111
describe ( 'default' , ( ) => {
107
112
beforeEach ( ( ) => {
108
- wrapper = shallowMount ( Quiz , { propsData } ) ;
113
+ wrapper = shallowMount ( Quiz , {
114
+ propsData,
115
+ stubs : { i18n : i18nStub } ,
116
+ } ) ;
109
117
} ) ;
110
118
111
119
it ( 'renders a div.quiz root' , ( ) => {
@@ -164,7 +172,11 @@ describe('Quiz', () => {
164
172
let submit ;
165
173
166
174
beforeEach ( ( ) => {
167
- wrapper = shallowMount ( Quiz , { propsData, attachToDocument : true } ) ;
175
+ wrapper = shallowMount ( Quiz , {
176
+ propsData,
177
+ stubs : { i18n : i18nStub } ,
178
+ attachToDocument : true ,
179
+ } ) ;
168
180
choices = wrapper . findAll ( '.choice' ) ;
169
181
submit = wrapper . find ( '.check' ) ;
170
182
} ) ;
@@ -199,21 +211,23 @@ describe('Quiz', () => {
199
211
} ) ;
200
212
201
213
it ( 'updates the aria live text telling the user if the answer chosen is correct or incorrect' , ( ) => {
202
- const ariaLive = wrapper . find ( '[aria-live="assertive"].visuallyhidden' ) ;
214
+ let ariaLive = wrapper . find ( '[aria-live="assertive"].visuallyhidden' ) ;
203
215
expect ( ariaLive . exists ( ) ) . toBe ( true ) ;
204
216
expect ( ariaLive . text ( ) ) . toBe ( '' ) ;
205
217
206
218
let choice = choices . at ( 1 ) ;
207
219
choice . trigger ( 'click' ) ;
208
220
submit . trigger ( 'click' ) ;
209
221
210
- expect ( ariaLive . text ( ) ) . toBe ( 'tutorials.assessment.answer-number-is 2 tutorials.assessment.incorrect' ) ;
222
+ ariaLive = wrapper . find ( '[aria-live="assertive"].visuallyhidden > span' ) ;
223
+ expect ( ariaLive . text ( ) ) . toBe ( 'Answer is tutorials.assessment.incorrect' ) ;
211
224
212
225
choice = choices . at ( 0 ) ;
213
226
choice . trigger ( 'click' ) ;
214
227
submit . trigger ( 'click' ) ;
215
228
216
- expect ( ariaLive . text ( ) ) . toBe ( 'tutorials.assessment.answer-number-is 1 tutorials.assessment.correct' ) ;
229
+ ariaLive = wrapper . find ( '[aria-live="assertive"].visuallyhidden > span' ) ;
230
+ expect ( ariaLive . text ( ) ) . toBe ( 'Answer is tutorials.assessment.correct' ) ;
217
231
} ) ;
218
232
} ) ;
219
233
} ) ;
0 commit comments