Skip to content

Commit 1a150e2

Browse files
author
Arman
committed
geophystech#137 Filters.
1 parent 2e3a07c commit 1a150e2

File tree

1 file changed

+26
-15
lines changed

1 file changed

+26
-15
lines changed

test/unit/specs/Filters.spec.js

+26-15
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,22 @@ import $moment from 'moment'
88
const localVue = createLocalVue()
99
localVue.use(BootstrapVue)
1010

11+
const fields = {
12+
datetime_max: { tag: 'input' },
13+
datetime_min: { tag: 'input' },
14+
depth_max: { tag: 'input' },
15+
depth_min: { tag: 'input' },
16+
has_mt: { tag: 'input[type=checkbox]' },
17+
mag_max: { tag: 'input' },
18+
mag_min: { tag: 'input' },
19+
lat_max: { tag: 'input' },
20+
lat_min: { tag: 'input' },
21+
lon_max: { tag: 'input' },
22+
lon_min: { tag: 'input' },
23+
rms_max: { tag: 'input' },
24+
sta_num_min: { tag: 'input' }
25+
}
26+
1127
describe('Filters.vue', () => {
1228

1329
const $store = {
@@ -18,6 +34,13 @@ describe('Filters.vue', () => {
1834
}
1935
}
2036

37+
$routerMocks.$route.query = {}
38+
const values = [false, '', '1', true]
39+
Object.keys(fields).forEach(prop => {
40+
values.push(values[0])
41+
$routerMocks.$route.query[prop] = values[0]
42+
})
43+
2144
const wrapper = mount(Filters, {
2245
mocks: Object.assign({ $moment, $store }, $routerMocks),
2346
attachToDocument: true,
@@ -28,27 +51,14 @@ describe('Filters.vue', () => {
2851
expect(wrapper.is(Filters)).to.eql(true)
2952
})
3053

31-
describeCheckFormFields(wrapper, {
32-
datetime_max: { tag: 'input' },
33-
datetime_min: { tag: 'input' },
34-
depth_max: { tag: 'input' },
35-
depth_min: { tag: 'input' },
36-
has_mt: { tag: 'input[type=checkbox]' },
37-
mag_max: { tag: 'input' },
38-
mag_min: { tag: 'input' },
39-
lat_max: { tag: 'input' },
40-
lat_min: { tag: 'input' },
41-
lon_max: { tag: 'input' },
42-
lon_min: { tag: 'input' },
43-
rms_max: { tag: 'input' },
44-
sta_num_min: { tag: 'input' }
45-
}, {
54+
describeCheckFormFields(wrapper, fields, {
4655
label: 'Check filter fields'
4756
})
4857

4958
describe('Filters Change', () => {
5059

5160
const magMinField = wrapper.find('input[name="mag_min"]')
61+
wrapper.vm._filtersUpdateTimeout = setTimeout(() => {})
5262

5363
it('Form change', async () => {
5464

@@ -68,6 +78,7 @@ describe('Filters.vue', () => {
6878
flushPromises().then(() => {
6979
expect(wrapper.vm.filtersChanged).to.equal(false)
7080
expect(wrapper.vm.sendBtnFade).to.equal(false)
81+
wrapper.trigger('reset')
7182
})
7283
})
7384

0 commit comments

Comments
 (0)