Skip to content

Commit b4ac4c4

Browse files
committed
test for closed
1 parent e4bccfd commit b4ac4c4

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

src/create-zero-composables.test.ts

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,16 +71,15 @@ describe('createZeroComposables', () => {
7171

7272
expect(zero.value.userID).toEqual('test-user')
7373

74-
// const oldZero = zero.value
74+
const oldZero = zero.value
7575

7676
userID.value = 'test-user-2'
7777
await nextTick()
78+
await new Promise(resolve => setTimeout(resolve, 1))
7879

7980
expect(zero.value.userID).toEqual('test-user-2')
8081
expect(zero.value.closed).toBe(false)
81-
82-
// TODO: Figure out a way to test this, since closing is async
83-
// expect(oldZero.closed).toBe(true)
82+
expect(oldZero.closed).toBe(true)
8483
})
8584

8685
it('useQuery works whithout explicitly calling useZero', async () => {
@@ -148,16 +147,15 @@ describe('createZeroComposables', () => {
148147

149148
expect(usedZero.value.userID).toEqual('test-user')
150149

151-
// const oldZero = usedZero.value
150+
const oldZero = usedZero.value
152151

153152
userID.value = 'test-user-2'
154153
await nextTick()
154+
await new Promise(resolve => setTimeout(resolve, 1))
155155

156156
expect(usedZero.value.userID).toEqual('test-user-2')
157157
expect(usedZero.value.closed).toBe(false)
158-
159-
// TODO: Figure out a way to test this, since closing is async
160-
// expect(oldZero.closed).toBe(true)
158+
expect(oldZero.closed).toBe(true)
161159
})
162160

163161
it('is created lazily and once', async () => {

tsconfig.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
"compilerOptions": {
33
"target": "es2022",
44
"lib": [
5-
"es2022"
5+
"es2022",
6+
"DOM"
67
],
78
"moduleDetection": "force",
89
"module": "preserve",

0 commit comments

Comments
 (0)