Skip to content

Commit 2742b0a

Browse files
committed
temp
1 parent 8bb4a43 commit 2742b0a

File tree

5 files changed

+1901
-39
lines changed

5 files changed

+1901
-39
lines changed

.eslintrc.js

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,16 @@ module.exports = {
1010
rules: {
1111
'no-console': process.env.NODE_ENV === 'production' ? 'warn' : 'off',
1212
'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+
]
1425
}

jest.config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
module.exports = {
2+
preset: '@vue/cli-plugin-unit-jest/presets/no-babel'
3+
}

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
"scripts": {
1919
"build": "rollup -c --environment BUILD:production",
2020
"dev": "rollup -c -w --environment BUILD:production",
21+
"test": "vue-cli-service test:unit",
2122
"lint": "vue-cli-service lint"
2223
},
2324
"devDependencies": {
@@ -26,8 +27,10 @@
2627
"@babel/preset-env": "^7.11.5",
2728
"@rollup/plugin-babel": "^5.2.2",
2829
"@vue/cli-plugin-eslint": "^4.5.4",
30+
"@vue/cli-plugin-unit-jest": "~4.5.0",
2931
"@vue/cli-service": "^4.5.4",
3032
"@vue/eslint-config-prettier": "^6.0.0",
33+
"@vue/test-utils": "^1.1.2",
3134
"babel-eslint": "10.1.0",
3235
"eslint": "6.7.2",
3336
"eslint-config-airbnb-base": "^14.2.0",

tests/unit/VueFinalModal.spec.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
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+
})

0 commit comments

Comments
 (0)