mirror of
https://github.com/tusen-ai/naive-ui.git
synced 2024-11-21 01:13:16 +08:00
test(button)
This commit is contained in:
parent
39f2b3c49a
commit
15b1254eb6
@ -54,11 +54,14 @@ module.exports = {
|
||||
}
|
||||
},
|
||||
{
|
||||
files: '*.spec.js',
|
||||
files: '*.spec.ts',
|
||||
globals: {
|
||||
describe: 'readonly',
|
||||
it: 'readonly',
|
||||
expect: 'readonly'
|
||||
},
|
||||
rules: {
|
||||
'@typescript-eslint/no-floating-promises': 0
|
||||
}
|
||||
},
|
||||
{
|
||||
|
@ -1,19 +0,0 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import create from '../../create'
|
||||
import { enUS } from '../../locales'
|
||||
import { buttonLight } from '../styles'
|
||||
import { NButton } from '../index'
|
||||
|
||||
describe('n-button', () => {
|
||||
const naive = create({
|
||||
locales: [enUS],
|
||||
styles: [buttonLight]
|
||||
})
|
||||
it('should work with import on demand', () => {
|
||||
mount(NButton, {
|
||||
global: {
|
||||
plugins: [naive]
|
||||
}
|
||||
})
|
||||
})
|
||||
})
|
29
src/button/tests/Button.spec.ts
Normal file
29
src/button/tests/Button.spec.ts
Normal file
@ -0,0 +1,29 @@
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { NButton } from '../index'
|
||||
|
||||
describe('n-button', () => {
|
||||
it('should work with import on demand', () => {
|
||||
mount(NButton)
|
||||
})
|
||||
it('clickable', () => {
|
||||
const onClick = jest.fn()
|
||||
const inst = mount(NButton, {
|
||||
props: {
|
||||
onClick
|
||||
}
|
||||
})
|
||||
inst.trigger('click')
|
||||
expect(onClick).toHaveBeenCalled()
|
||||
})
|
||||
it('disabled', () => {
|
||||
const onClick = jest.fn()
|
||||
const inst = mount(NButton, {
|
||||
props: {
|
||||
disabled: true,
|
||||
onClick
|
||||
}
|
||||
})
|
||||
inst.trigger('click')
|
||||
expect(onClick).not.toHaveBeenCalled()
|
||||
})
|
||||
})
|
Loading…
Reference in New Issue
Block a user