@@ -220,8 +220,8 @@ describe('EditLanguageModal', () => {
220220 } ) ;
221221
222222 describe ( 'topic nodes present' , ( ) => {
223- it ( 'should display the checkbox to apply change to descendants if a topic is present' , ( ) => {
224- [ wrapper ] = makeWrapper ( [ 'test-en-topic' , 'test-en-res' ] ) ;
223+ test ( 'should display a selected checkbox to apply change to descendants if a topic is present' , ( ) => {
224+ const [ wrapper ] = makeWrapper ( [ 'test-en-topic' , 'test-en-res' ] ) ;
225225
226226 expect (
227227 wrapper . findComponent ( '[data-test="update-descendants-checkbox"]' ) . exists ( ) ,
@@ -236,30 +236,33 @@ describe('EditLanguageModal', () => {
236236 ) . toBeFalsy ( ) ;
237237 } ) ;
238238
239- it ( 'should call updateContentNode with the right language on success submit if the user does not check the checkbox ' , async ( ) => {
240- [ wrapper , mocks ] = makeWrapper ( [ 'test-en-topic' , 'test-en-res' ] ) ;
239+ test ( 'should call updateContentNodeDescendants with the right language on success submit by default ' , async ( ) => {
240+ const [ wrapper , mocks ] = makeWrapper ( [ 'test-en-topic' , 'test-en-res' ] ) ;
241241
242242 await chooseLanguage ( wrapper , 'es' ) ;
243243 await wrapper . vm . handleSave ( ) ;
244- await wrapper . vm . $nextTick ( ) ;
245244
246- expect ( mocks . updateContentNode ) . toHaveBeenCalledWith ( {
245+ expect ( mocks . updateContentNodeDescendants ) . toHaveBeenCalledWith ( {
247246 id : 'test-en-topic' ,
248247 language : 'es' ,
249248 } ) ;
250249 } ) ;
251250
252- it ( 'should call updateContentNodeDescendants with the right language on success submit if the user checks the checkbox' , async ( ) => {
253- [ wrapper , mocks ] = makeWrapper ( [ 'test-en-topic' , 'test-en-res' ] ) ;
251+ test ( 'should call updateContentNode with the right language on success submit if the user unchecks check the checkbox' , async ( ) => {
252+ const [ wrapper , mocks ] = makeWrapper ( [ 'test-en-topic' , 'test-en-res' ] ) ;
254253
255254 await chooseLanguage ( wrapper , 'es' ) ;
256- wrapper . findComponent ( '[data-test="update-descendants-checkbox"]' ) . vm . $emit ( 'change' , true ) ;
255+
256+ // Uncheck the descendants checkbox
257+ const descendantsCheckbox = wrapper . findComponent (
258+ '[data-test="update-descendants-checkbox"]' ,
259+ ) ;
260+ descendantsCheckbox . vm . $emit ( 'change' , false ) ;
257261 await wrapper . vm . $nextTick ( ) ;
258- expect ( wrapper . vm . updateDescendants ) . toBe ( true ) ;
262+
259263 await wrapper . vm . handleSave ( ) ;
260- await wrapper . vm . $nextTick ( ) ;
261264
262- expect ( mocks . updateContentNodeDescendants ) . toHaveBeenCalledWith ( {
265+ expect ( mocks . updateContentNode ) . toHaveBeenCalledWith ( {
263266 id : 'test-en-topic' ,
264267 language : 'es' ,
265268 } ) ;
0 commit comments