Skip to content

Commit 372e06c

Browse files
committed
test: simplify unknown listener assertion
1 parent 0b53ab2 commit 372e06c

1 file changed

Lines changed: 2 additions & 9 deletions

File tree

packages/devframe/src/in-page-channel/in-page-channel.test.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import type { ConnectPanelChannelOptions, CreatePageScriptChannelOptions, InPageChannelProtocol, PageScriptChannel, PanelChannel } from './types'
2-
import { Diagnostic } from 'devframe/utils/nostics'
32
import { describe, expect, it, vi } from 'vitest'
43
import { InPageChannelError } from './internal'
54
import { createPageScriptChannel } from './page-script'
@@ -125,15 +124,9 @@ describe('in-page channel over bring-your-own ports', () => {
125124
const warn = vi.spyOn(console, 'warn').mockImplementation(() => {})
126125
const { panel, dispose } = createLinkedPair()
127126
try {
128-
let rejection: unknown
129-
try {
127+
expect(() => {
130128
panel.on('missing' as any, () => {})
131-
}
132-
catch (error) {
133-
rejection = error
134-
}
135-
expect(rejection).toBeInstanceOf(Diagnostic)
136-
expect(rejection).toMatchObject({ name: 'DF0077' })
129+
}).toThrowError(expect.objectContaining({ name: 'DF0077' }))
137130
expect(warn).toHaveBeenCalledOnce()
138131
expect(warn).toHaveBeenCalledWith(expect.stringContaining('[DF0077]'))
139132
}

0 commit comments

Comments
 (0)