Skip to content

Commit c5983f4

Browse files
committed
test: add unit tests for StudioOfflineAlert
1 parent 6f06b67 commit c5983f4

1 file changed

Lines changed: 40 additions & 0 deletions

File tree

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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+

0 commit comments

Comments
 (0)