mirror of
https://gitee.com/element-plus/element-plus.git
synced 2024-12-15 09:50:58 +08:00
1d13ebb05d
* feat: drop jest * test: remove ssr * test: rename * chore: update tsconfig
27 lines
690 B
TypeScript
27 lines
690 B
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { debugWarn, throwError } from '..'
|
|
|
|
describe('error', () => {
|
|
it('throwError should work', () => {
|
|
expect(() =>
|
|
throwError('scope', 'message')
|
|
).toThrowErrorMatchingInlineSnapshot('"[scope] message"')
|
|
})
|
|
|
|
it('debugWarn should work', () => {
|
|
const warnFn = vi.spyOn(console, 'warn').mockImplementation(() => vi.fn)
|
|
debugWarn('scope', 'message')
|
|
debugWarn(new SyntaxError('custom error'))
|
|
expect(warnFn.mock.calls).toMatchInlineSnapshot(`
|
|
[
|
|
[
|
|
[ElementPlusError: [scope] message],
|
|
],
|
|
[
|
|
[SyntaxError: custom error],
|
|
],
|
|
]
|
|
`)
|
|
})
|
|
})
|