@@ -36,20 +36,22 @@ describe('Snack Notification Component', () => {
3636 wrapper . destroy ( )
3737 } )
3838
39- it ( 'It should contain a `p` element and close icon' , ( ) => {
39+ it ( 'It should contain a `p` element and close icon' , async ( ) => {
40+ await Vue . nextTick ( )
4041 expect ( wrapper . find ( '#snack-message' ) . exists ( ) ) . toBeTruthy ( )
41- expect ( wrapper . find ( '#close-icon' ) . exists ( ) ) . toBeTruthy ( )
42+ expect ( wrapper . findComponent ( { ref : 'close-btn' } ) . exists ( ) ) . toBeTrue ( )
43+ expect ( wrapper . findComponent ( { ref : 'close-btn' } ) . text ( ) ) . toEqual ( 'Close' )
4244 } )
4345
44- it ( 'Displayed text changes with `peerConnectionStatus` state' , ( ) => {
46+ it ( 'Displayed text changes with `peerConnectionStatus` state' , async ( ) => {
4547 store . state . pnp . peerConnectionStatus = PEER_CONNECTING
4648 const connectingComp = mount ( StatusSnackbar , {
4749 localVue,
4850 vuetify,
4951 store
5052 } )
53+ await Vue . nextTick ( )
5154 expect ( connectingComp . find ( '#snack-message' ) . text ( ) ) . toBe ( PEER_CONNECTING_NOTIFICATION )
52-
5355 store . state . pnp . peerConnectionStatus = PEER_CONNECTED
5456 const connectedComp = mount ( StatusSnackbar , {
5557 localVue,
@@ -65,17 +67,14 @@ describe('Snack Notification Component', () => {
6567 store
6668 } )
6769 expect ( disconnectedComp . find ( '#snack-message' ) . text ( ) ) . toBe ( PEER_DISCONNECTED_NOTIFICATION )
70+ expect ( wrapper . findComponent ( { ref : 'close-btn' } ) . exists ( ) ) . toBeTrue ( )
71+ expect ( wrapper . findComponent ( { ref : 'close-btn' } ) . text ( ) ) . toEqual ( 'Close' )
6872 } )
6973
70- it ( '`peerConnectionStatus` status controls StatusSnackbar visibility' , ( ) => {
74+ it ( '`peerConnectionStatus` status controls StatusSnackbar visibility' , async ( ) => {
7175 store . state . pnp . peerConnectionStatus = PEER_CONNECTED
7276
73- const newComponent = mount ( StatusSnackbar , {
74- localVue,
75- vuetify,
76- store
77- } )
78-
79- expect ( newComponent . find ( '#snack-message' ) . exists ( ) ) . toBeTruthy ( )
77+ expect ( wrapper . findComponent ( { ref : 'close-btn' } ) . exists ( ) ) . toBeTrue ( )
78+ expect ( wrapper . findComponent ( { ref : 'close-btn' } ) . text ( ) ) . toEqual ( 'Close' )
8079 } )
8180} )
0 commit comments