test(session): cover preparation disposal directly
This commit is contained in:
1 parent
7289bee231
commit
55e45b52c9
1 file changed
+21
@@ -0,0 +1,21 @@
|
||||
import { describe, expect, it, vi } from 'vitest'
|
||||
import { Session, SessionId, SessionPreparation } from '@deepseek-ai/dsh-session'
|
||||
|
||||
describe('SessionPreparation', () => {
|
||||
it('retains the exact Session and releases provider state only once', () => {
|
||||
const session = Session.create(SessionId('prepared'))
|
||||
const release = vi.fn()
|
||||
{
|
||||
using preparation = SessionPreparation.create(session, { release })
|
||||
expect(preparation.session).toBe(session)
|
||||
preparation[Symbol.dispose]()
|
||||
expect(release).toHaveBeenCalledOnce()
|
||||
}
|
||||
expect(release).toHaveBeenCalledOnce()
|
||||
})
|
||||
|
||||
it('disposes a preparation without provider state', () => {
|
||||
using preparation = SessionPreparation.create(Session.create(SessionId('unretained')))
|
||||
expect(() => { preparation[Symbol.dispose]() }).not.toThrow()
|
||||
})
|
||||
})
|
||||
Reference in new issue
Block a user