File tree Expand file tree Collapse file tree 5 files changed +1901
-39
lines changed Expand file tree Collapse file tree 5 files changed +1901
-39
lines changed Original file line number Diff line number Diff line change @@ -10,5 +10,16 @@ module.exports = {
10
10
rules : {
11
11
'no-console' : process . env . NODE_ENV === 'production' ? 'warn' : 'off' ,
12
12
'no-debugger' : process . env . NODE_ENV === 'production' ? 'warn' : 'off'
13
- }
13
+ } ,
14
+ overrides : [
15
+ {
16
+ files : [
17
+ '**/__tests__/*.{j,t}s?(x)' ,
18
+ '**/tests/unit/**/*.spec.{j,t}s?(x)'
19
+ ] ,
20
+ env : {
21
+ jest : true
22
+ }
23
+ }
24
+ ]
14
25
}
Original file line number Diff line number Diff line change
1
+ module . exports = {
2
+ preset : '@vue/cli-plugin-unit-jest/presets/no-babel'
3
+ }
Original file line number Diff line number Diff line change 18
18
"scripts" : {
19
19
"build" : " rollup -c --environment BUILD:production" ,
20
20
"dev" : " rollup -c -w --environment BUILD:production" ,
21
+ "test" : " vue-cli-service test:unit" ,
21
22
"lint" : " vue-cli-service lint"
22
23
},
23
24
"devDependencies" : {
26
27
"@babel/preset-env" : " ^7.11.5" ,
27
28
"@rollup/plugin-babel" : " ^5.2.2" ,
28
29
"@vue/cli-plugin-eslint" : " ^4.5.4" ,
30
+ "@vue/cli-plugin-unit-jest" : " ~4.5.0" ,
29
31
"@vue/cli-service" : " ^4.5.4" ,
30
32
"@vue/eslint-config-prettier" : " ^6.0.0" ,
33
+ "@vue/test-utils" : " ^1.1.2" ,
31
34
"babel-eslint" : " 10.1.0" ,
32
35
"eslint" : " 6.7.2" ,
33
36
"eslint-config-airbnb-base" : " ^14.2.0" ,
Original file line number Diff line number Diff line change
1
+ import { createLocalVue , mount } from '@vue/test-utils'
2
+ import VueFinalModal from '../../lib'
3
+
4
+ function createOpenedModal ( propsData = { } , mountingOptions = { } ) {
5
+ const localVue = createLocalVue ( )
6
+ localVue . use ( VueFinalModal ( ) )
7
+ return new Promise ( resolve => {
8
+ const wrapper = mount ( localVue . options . components . VueFinalModal , {
9
+ stubs : false ,
10
+ localVue,
11
+ propsData : {
12
+ value : true ,
13
+ ...propsData
14
+ } ,
15
+ listeners : {
16
+ opened : ( ) => resolve ( { wrapper, localVue } )
17
+ } ,
18
+ ...mountingOptions
19
+ } )
20
+ } )
21
+ }
22
+
23
+ describe ( 'VueFinalModal.vue' , ( ) => {
24
+ describe ( 'props' , ( ) => {
25
+ it ( 'value' , async ( ) => {
26
+ const { wrapper } = await createOpenedModal ( )
27
+ expect ( wrapper . find ( '.vfm' ) . isVisible ( ) ) . toBe ( true )
28
+ } )
29
+ it ( 'lockScroll: true' , async ( ) => {
30
+ await createOpenedModal ( {
31
+ lockScroll : true
32
+ } )
33
+ expect ( document . body . style . overflow ) . toBe ( 'hidden' )
34
+ } )
35
+ it ( 'lockScroll: false' , async ( ) => {
36
+ await createOpenedModal ( {
37
+ lockScroll : false
38
+ } )
39
+ expect ( document . body . style . overflow ) . not . toBe ( 'hidden' )
40
+ } )
41
+ } )
42
+ } )
You can’t perform that action at this time.
0 commit comments