1+ import { createLocalVue , mount } from '@vue/test-utils'
2+ import Buefy from 'buefy'
3+ import Vuex from 'vuex'
4+ import CopyrightWaiverStep from '@/components/CopyrightWaiverStep'
5+
6+ const localVue = createLocalVue ( )
7+
8+ localVue . use ( Vuex )
9+ localVue . use ( Buefy )
10+
11+ describe ( 'CopyrightWaiver Step: Check conditional rendering of markup' , ( ) => {
12+ let wrapper , state
13+
14+ beforeEach ( ( ) => {
15+ wrapper = mount ( CopyrightWaiverStep , {
16+ localVue,
17+ data ( ) {
18+ return {
19+ agreed : false ,
20+ confirmed : false
21+ }
22+ } ,
23+ mocks : {
24+ $t : key => key ,
25+ }
26+ } )
27+ } )
28+
29+ afterEach ( ( ) => {
30+ wrapper . destroy ( )
31+ } )
32+
33+ it ( 'Component not mounted if status is inactive' , ( ) => {
34+ wrapper . setProps ( {
35+ selected : undefined ,
36+ status : 'inactive' ,
37+ stepId : 6 ,
38+ stepName : 'CW' ,
39+ } )
40+
41+ expect ( wrapper . find ( '.step-description' ) . exists ( ) ) . toBeFalsy
42+ expect ( wrapper . find ( '.step-actions' ) . exists ( ) ) . toBeFalsy ( )
43+ } )
44+
45+ it ( 'Step Description block mounted if status is previous' , ( ) => {
46+ wrapper . setProps ( { status : 'previous' } )
47+
48+ expect ( wrapper . find ( '.step-description' ) . exists ( ) ) . toBeTruthy ( )
49+ expect ( wrapper . find ( '.step-actions' ) . exists ( ) ) . toBeFalsy ( )
50+ } )
51+
52+ it ( 'Step Actions block mounted if status is current' , ( ) => {
53+ wrapper . setProps ( { status : 'current' } )
54+
55+ expect ( wrapper . find ( '.step-description' ) . exists ( ) ) . toBeFalsy ( )
56+ expect ( wrapper . find ( '.step-actions' ) . exists ( ) ) . toBeTruthy ( )
57+ expect ( wrapper . vm . copyrightWaiverAgreed ) . toBe ( false )
58+ } )
59+
60+ it ( 'User clicks copyright waiver checkbox' , ( ) => {
61+ wrapper . setProps ( { status : 'current' } )
62+
63+ const checkbox = wrapper . findAll ( 'input[type="checkbox"]' ) . at ( 0 )
64+ checkbox . setChecked ( ) ;
65+
66+ console . log ( wrapper . emitted ( ) )
67+
68+ } )
69+
70+ } )
71+
72+ describe ( 'Test functionality of computed properties' , ( ) => {
73+ let wrapper
74+
75+ beforeEach ( ( ) => {
76+ wrapper = mount ( CopyrightWaiverStep , {
77+ localVue,
78+ propsData :{
79+ selected : undefined ,
80+ status : 'current' ,
81+ stepId : 6 ,
82+ stepName : 'CW' ,
83+ } ,
84+ mocks : {
85+ $t : key => key ,
86+ }
87+ } )
88+ } )
89+
90+ afterEach ( ( ) => {
91+ wrapper . destroy ( )
92+ } )
93+
94+ it ( 'User checks agreed with confirmed checked' , ( ) => {
95+ wrapper . setData ( {
96+ agreed : false ,
97+ confirmed : true
98+ } )
99+
100+ const checkbox = wrapper . findAll ( 'input[type="checkbox"]' ) . at ( 0 )
101+ checkbox . setChecked ( ) ;
102+
103+ expect ( wrapper . emitted ( ) . change [ 0 ] ) . toStrictEqual ( [ 'CW' , 6 , true ] )
104+ } )
105+
106+ it ( 'User checks confirmed with agreed checked' , ( ) => {
107+ wrapper . setData ( {
108+ agreed : true ,
109+ confirmed : false
110+ } )
111+
112+ const checkbox = wrapper . findAll ( 'input[type="checkbox"]' ) . at ( 1 )
113+ checkbox . setChecked ( ) ;
114+
115+ expect ( wrapper . emitted ( ) . change [ 0 ] ) . toStrictEqual ( [ 'CW' , 6 , true ] )
116+ } )
117+
118+ } )
0 commit comments