2019-01-24 20:15:10 +00:00
|
|
|
// Copyright (C) 2019 Storj Labs, Inc.
|
2018-11-27 10:51:33 +00:00
|
|
|
// See LICENSE for copying information.
|
|
|
|
|
2018-11-16 14:28:02 +00:00
|
|
|
import HeaderlessInput from '@/components/common/HeaderlessInput.vue';
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
import { mount, shallowMount } from '@vue/test-utils';
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2019-09-09 11:33:39 +01:00
|
|
|
describe('HeaderlessInput.vue', () => {
|
2019-02-20 13:33:56 +00:00
|
|
|
it('renders correctly with default props', () => {
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
const wrapper = shallowMount(HeaderlessInput);
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
it('renders correctly with size props', () => {
|
2019-09-09 11:33:39 +01:00
|
|
|
const placeholder = 'test';
|
|
|
|
const width = '30px';
|
|
|
|
const height = '20px';
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
const wrapper = shallowMount(HeaderlessInput, {
|
|
|
|
propsData: {placeholder, width, height}
|
|
|
|
});
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
expect(wrapper.find('input').element.style.width).toMatch(width);
|
|
|
|
expect(wrapper.find('input').element.style.height).toMatch(height);
|
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
it('renders correctly with isPassword prop', () => {
|
|
|
|
const wrapper = mount(HeaderlessInput, {
|
|
|
|
propsData: {isPassword: true}
|
|
|
|
});
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
expect(wrapper).toMatchSnapshot();
|
|
|
|
});
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
it('emit setData on input correctly', () => {
|
2019-09-09 11:33:39 +01:00
|
|
|
const testData = 'testData';
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
const wrapper = mount(HeaderlessInput);
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
wrapper.find('input').trigger('input');
|
2018-12-18 14:43:23 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
expect(wrapper.emitted('setData').length).toEqual(1);
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
wrapper.vm.$emit('setData', testData);
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2019-02-20 13:33:56 +00:00
|
|
|
expect(wrapper.emitted('setData')[1][0]).toEqual(testData);
|
|
|
|
});
|
2018-11-14 14:57:21 +00:00
|
|
|
|
2018-12-18 14:43:23 +00:00
|
|
|
});
|