forked from jd-opensource/nutui
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
31a33a2
commit d7718fc
Showing
5 changed files
with
43 additions
and
7 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
module.exports = { | ||
moduleFileExtensions: ['vue', 'js', 'ts'], | ||
preset: 'ts-jest', | ||
testEnvironment: 'jsdom', | ||
transform: { | ||
'^.+\\.vue$': 'vue-jest', // vue 文件用 vue-jest 转换 | ||
'^.+\\.ts$': 'ts-jest' // ts 文件用 ts-jest 转换 | ||
}, | ||
// 匹配 __tests__ 目录下的 .js/.ts 文件 或其他目录下的 xx.test.js/ts xx.spec.js/ts | ||
testRegex: '(/__tests__/.*|(\\.|/)(test|spec))\\.(ts)$', | ||
// 支持源代码中相同的 `@` -> `src` 别名 | ||
moduleNameMapper: { | ||
'^@/(.*)$': '<rootDir>/src/$1' | ||
} | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { mount } from '@vue/test-utils'; | ||
import Button from '../index.vue'; | ||
|
||
test('emit click event', () => { | ||
const wrapper = mount(Button); | ||
|
||
wrapper.trigger('click'); | ||
expect(wrapper.emitted('click')!.length).toEqual(1); | ||
}); | ||
|
||
test('slot test', async () => { | ||
const wrapper = mount(Button, { | ||
slots: { | ||
default: '按钮测试' | ||
} | ||
}); | ||
expect(wrapper.html()).toContain('按钮测试'); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters