test(button)

This commit is contained in:
07akioni 2021-02-17 15:04:19 +08:00
parent 39f2b3c49a
commit 15b1254eb6
3 changed files with 33 additions and 20 deletions

View File

@ -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
}
},
{

View File

@ -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]
}
})
})
})

View 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()
})
})