File tree Expand file tree Collapse file tree
contentcuration/contentcuration/frontend/shared/views/__tests__ Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ import { mount } from '@vue/test-utils' ;
2+ import StudioOfflineAlert from '../StudioOfflineAlert.vue' ;
3+ import storeFactory from 'shared/vuex/baseStore' ;
4+
5+ function makeWrapper ( ) {
6+ const store = storeFactory ( ) ;
7+ return {
8+ wrapper : mount ( StudioOfflineAlert , {
9+ store,
10+ } ) ,
11+ store,
12+ } ;
13+ }
14+
15+ describe ( 'StudioOfflineAlert' , ( ) => {
16+ let wrapper , store ;
17+
18+ beforeEach ( ( ) => {
19+ const setup = makeWrapper ( ) ;
20+ wrapper = setup . wrapper ;
21+ store = setup . store ;
22+ } ) ;
23+
24+ it ( 'displays alert component when offline' , async ( ) => {
25+ store . state . connection . online = false ;
26+ await wrapper . vm . $nextTick ( ) ;
27+
28+ expect ( wrapper . find ( '[data-test="studio-offline-alert"]' ) . exists ( ) ) . toBe ( true ) ;
29+ expect ( wrapper . text ( ) ) . toMatch ( "You seem to be offline. Your changes will be saved once your connection is back" ) ;
30+ } ) ;
31+
32+ it ( 'hides alert component when online' , async ( ) => {
33+ store . state . connection . online = true ;
34+ await wrapper . vm . $nextTick ( ) ;
35+
36+ expect ( wrapper . find ( '[data-test="studio-offline-alert"]' ) . exists ( ) ) . toBe ( false ) ;
37+ } ) ;
38+
39+ } ) ;
40+
You can’t perform that action at this time.
0 commit comments