NWJS_Hour_Tracking/tests/unit/components/FsExample.test.js

46 lines
1.1 KiB
JavaScript
Raw Normal View History

2019-10-29 10:27:18 -06:00
import { shallowMount } from '@vue/test-utils';
import FsExample from '@/components/FsExample.vue';
describe('FsExample.vue', () => {
test('Render default contents', () => {
const wrapper = shallowMount(FsExample);
2020-01-23 17:43:40 -07:00
expect(wrapper)
2019-10-29 10:27:18 -06:00
.toMatchSnapshot();
});
2020-02-19 09:34:27 -07:00
test('Click button', async () => {
2019-10-29 10:27:18 -06:00
const wrapper = shallowMount(FsExample);
let domButton = wrapper.find('[data-test="fs-example-button"]');
domButton.trigger('click');
2020-02-19 09:34:27 -07:00
await wrapper.vm.$nextTick();
2019-10-29 10:27:18 -06:00
expect(window.nw.require)
.toHaveBeenCalledWith('fs');
2020-01-23 17:43:40 -07:00
expect(wrapper)
2019-10-29 10:27:18 -06:00
.toMatchSnapshot();
});
2020-02-19 09:34:27 -07:00
test('Error state', async () => {
2019-10-29 10:27:18 -06:00
window.nw.require.mockImplementation((module) => {
if (module === 'fs') {
return new Error();
}
});
const wrapper = shallowMount(FsExample);
let domButton = wrapper.find('[data-test="fs-example-button"]');
domButton.trigger('click');
2020-02-19 09:34:27 -07:00
await wrapper.vm.$nextTick();
2019-10-29 10:27:18 -06:00
expect(window.nw.require)
.toHaveBeenCalledWith('fs');
2020-01-23 17:43:40 -07:00
expect(wrapper)
2019-10-29 10:27:18 -06:00
.toMatchSnapshot();
});
});