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

42 lines
1001 B
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();
});
test('Click button', () => {
const wrapper = shallowMount(FsExample);
let domButton = wrapper.find('[data-test="fs-example-button"]');
domButton.trigger('click');
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();
});
test('Error state', () => {
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');
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();
});
});