NWJS_Hour_Tracking/tests/unit/components/FsExample.test.js
The Jared Wilcurt 05f0b399bf Update tests
2019-10-29 12:27:18 -04:00

42 lines
1022 B
JavaScript

import { shallowMount } from '@vue/test-utils';
import FsExample from '@/components/FsExample.vue';
describe('FsExample.vue', () => {
test('Render default contents', () => {
const wrapper = shallowMount(FsExample);
expect(wrapper.html())
.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');
expect(wrapper.html())
.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');
expect(wrapper.html())
.toMatchSnapshot();
});
});