mirror of
https://github.com/element-plus/element-plus.git
synced 2025-12-19 09:09:40 +08:00
* feat: support node 18+ & update tsx and vitest * chore: update * chore: remove * fix: update dep * test: fix autocomplete * test: update * test: update * chore: update * chore: update * chore: update
27 lines
708 B
TypeScript
27 lines
708 B
TypeScript
import { describe, expect, it, vi } from 'vitest'
|
|
import { debugWarn, throwError } from '..'
|
|
|
|
describe('error', () => {
|
|
it('throwError should work', () => {
|
|
expect(() =>
|
|
throwError('scope', 'message')
|
|
).toThrowErrorMatchingInlineSnapshot(`[ElementPlusError: [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],
|
|
],
|
|
]
|
|
`)
|
|
})
|
|
})
|