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

40 lines
995 B
JavaScript
Raw Normal View History

2019-09-15 22:49:40 -06:00
import { shallowMount, mount } from '@vue/test-utils';
import HelloWorld from '@/components/HelloWorld.vue';
describe('HelloWorld.vue', () => {
test('Render props.msg', () => {
const msg = 'new message';
const wrapper = shallowMount(HelloWorld, {
propsData: { msg }
});
expect(wrapper.find('[data-test="message"]').text())
.toEqual(msg);
});
test('Render default contents', () => {
const wrapper = mount(HelloWorld);
2020-01-23 17:43:40 -07:00
expect(wrapper)
2019-09-15 22:49:40 -06:00
.toMatchSnapshot();
});
2020-02-19 09:34:27 -07:00
test('Activate dev tools', async () => {
2019-09-15 22:49:40 -06:00
const wrapper = shallowMount(HelloWorld);
const button = wrapper.find('[data-test="toggleDevTools"]');
button.trigger('click');
2020-02-19 09:34:27 -07:00
await wrapper.vm.$nextTick();
2019-09-15 22:49:40 -06:00
expect(wrapper.find('[data-test="toggleDevTools').html())
.toMatchSnapshot('hide');
button.trigger('click');
2020-02-19 09:34:27 -07:00
await wrapper.vm.$nextTick();
2019-09-15 22:49:40 -06:00
expect(wrapper.find('[data-test="toggleDevTools').html())
.toMatchSnapshot('show');
});
});