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

51 lines
1.1 KiB
JavaScript
Raw Permalink Normal View History

2019-09-15 22:49:40 -06:00
import { shallowMount } from '@vue/test-utils';
import LinkList from '@/components/LinkList.vue';
describe('LinkList.vue', () => {
const link = {
name: 'Site',
url: 'https://nwjs.io'
};
test('Validate props', () => {
const wrapper = shallowMount(LinkList);
const links = wrapper.vm.$options.props.links;
expect(links.required)
.toBeFalsy();
expect(links.type)
.toBe(Array);
expect(links.default)
.toBeNull();
expect(links.validator && links.validator([{ name: '', url: '' }]))
.toBeFalsy();
expect(links.validator && links.validator([link]))
.toBeTruthy();
});
test('Render default contents', () => {
const wrapper = shallowMount(LinkList, {
propsData: { links: [link] }
});
2020-01-23 17:43:40 -07:00
expect(wrapper)
2019-09-15 22:49:40 -06:00
.toMatchSnapshot();
});
test('Click link', () => {
const wrapper = shallowMount(LinkList, {
propsData: { links: [link] }
});
let domLink = wrapper.findAll('[data-test="link"]').at(0);
domLink.trigger('click');
expect(window.nw.Shell.openExternal)
.toHaveBeenCalledWith('https://nwjs.io');
});
});