-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathSelect.spec.js
More file actions
54 lines (51 loc) · 1.94 KB
/
Copy pathSelect.spec.js
File metadata and controls
54 lines (51 loc) · 1.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import { mount, createLocalVue } from '@vue/test-utils'
import Select from './index.vue'
const propsData = { value: null }
const localVue = createLocalVue()
describe('Select', () => {
/** Mount */
describe('Mount', () => {
test('is a Vue instance', () => {
const wrapper = mount(Select, { propsData })
expect(wrapper.isVueInstance()).toBeTruthy()
})
})
/** Props */
describe('Props', () => {
test('have to disable the HTML select', () => {
const nPropsData = { ...propsData, disabled: true }
const wrapper = mount(Select, { propsData: nPropsData })
const attributes = wrapper.find('select').attributes('disabled')
expect(attributes).toBe('disabled')
})
test('have enable a loading', () => {
const nPropsData = { ...propsData, loading: true }
const wrapper = mount(Select, { localVue, propsData: nPropsData })
expect(wrapper.find('.select--status.fa-spinner')).toBeTruthy()
})
})
/** Events */
describe('Events', () => {
test('have a HTML select what is changed', () => {
const wrapper = mount(Select, { propsData })
wrapper.find('select').setValue('test')
expect(wrapper.emitted().input).toBeTruthy()
})
test('have "chevron-down" icon when inactive', () => {
const wrapper = mount(Select, { propsData })
wrapper.setData({ active: false })
expect(wrapper.find('.select--status.fa-chevron-down')).toBeTruthy()
})
test('have "chevron-up" icon when active', () => {
const wrapper = mount(Select, { propsData })
wrapper.setData({ active: true })
expect(wrapper.find('.select--status.fa-chevron-up')).toBeTruthy()
})
test('have a HTML select what is not changed when disabled', () => {
const nPropsData = { ...propsData, disabled: true }
const wrapper = mount(Select, { propsData: nPropsData })
wrapper.find('select').setValue('test')
expect(wrapper.emitted().input).toBeFalsy()
})
})
})