@@ -8,6 +8,22 @@ import $moment from 'moment'
8
8
const localVue = createLocalVue ( )
9
9
localVue . use ( BootstrapVue )
10
10
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
+
11
27
describe ( 'Filters.vue' , ( ) => {
12
28
13
29
const $store = {
@@ -18,6 +34,13 @@ describe('Filters.vue', () => {
18
34
}
19
35
}
20
36
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
+
21
44
const wrapper = mount ( Filters , {
22
45
mocks : Object . assign ( { $moment, $store } , $routerMocks ) ,
23
46
attachToDocument : true ,
@@ -28,27 +51,14 @@ describe('Filters.vue', () => {
28
51
expect ( wrapper . is ( Filters ) ) . to . eql ( true )
29
52
} )
30
53
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 , {
46
55
label : 'Check filter fields'
47
56
} )
48
57
49
58
describe ( 'Filters Change' , ( ) => {
50
59
51
60
const magMinField = wrapper . find ( 'input[name="mag_min"]' )
61
+ wrapper . vm . _filtersUpdateTimeout = setTimeout ( ( ) => { } )
52
62
53
63
it ( 'Form change' , async ( ) => {
54
64
@@ -68,6 +78,7 @@ describe('Filters.vue', () => {
68
78
flushPromises ( ) . then ( ( ) => {
69
79
expect ( wrapper . vm . filtersChanged ) . to . equal ( false )
70
80
expect ( wrapper . vm . sendBtnFade ) . to . equal ( false )
81
+ wrapper . trigger ( 'reset' )
71
82
} )
72
83
} )
73
84
0 commit comments