Skip to content

Commit f94e892

Browse files
committed
chore: fix types after upgrades
1 parent a1e5131 commit f94e892

File tree

8 files changed

+162
-109
lines changed

8 files changed

+162
-109
lines changed

tests/database/list.spec.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,15 @@ import {
77
_RefDatabase,
88
} from '../../src'
99
import { expectType, tds, setupDatabaseRefs, database } from '../utils'
10-
import { computed, nextTick, ref, unref, watch, type Ref } from 'vue'
10+
import {
11+
computed,
12+
nextTick,
13+
ref,
14+
unref,
15+
watch,
16+
type Ref,
17+
defineComponent,
18+
} from 'vue'
1119
import {
1220
DatabaseReference,
1321
orderByChild,
@@ -31,14 +39,16 @@ describe('Database lists', () => {
3139
} = {}) {
3240
let data!: _RefDatabase<VueDatabaseQueryData<T>>
3341

34-
const wrapper = mount({
35-
template: 'no',
36-
setup() {
37-
data = useDatabaseList(ref, options)
38-
const { data: list, pending, error, promise, stop } = data
39-
return { list, pending, error, promise, stop }
40-
},
41-
})
42+
const wrapper = mount(
43+
defineComponent({
44+
template: 'no',
45+
setup() {
46+
data = useDatabaseList(ref, options)
47+
const { data: list, pending, error, promise, stop } = data
48+
return { list, pending, error, promise, stop }
49+
},
50+
})
51+
)
4252

4353
return {
4454
wrapper,

tests/database/objects.spec.ts

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,15 @@ import {
1414
database,
1515
firebaseApp,
1616
} from '../utils'
17-
import { computed, nextTick, ref, shallowRef, unref, type Ref } from 'vue'
17+
import {
18+
computed,
19+
nextTick,
20+
ref,
21+
shallowRef,
22+
unref,
23+
type Ref,
24+
defineComponent,
25+
} from 'vue'
1826
import { DatabaseReference, get, ref as _databaseRef } from 'firebase/database'
1927
import { _MaybeRef, _Nullable } from '../../src/shared'
2028
import { mockWarn } from '../vitest-mock-warn'
@@ -33,14 +41,16 @@ describe('Database objects', () => {
3341
} = {}) {
3442
let data!: _RefDatabase<VueDatabaseDocumentData<T> | undefined>
3543

36-
const wrapper = mount({
37-
template: 'no',
38-
setup() {
39-
data = useDatabaseObject(ref, options)
40-
const { data: item, pending, error, promise, stop } = data
41-
return { item, pending, error, promise, stop }
42-
},
43-
})
44+
const wrapper = mount(
45+
defineComponent({
46+
template: 'no',
47+
setup() {
48+
data = useDatabaseObject(ref, options)
49+
const { data: item, pending, error, promise, stop } = data
50+
return { item, pending, error, promise, stop }
51+
},
52+
})
53+
)
4454

4555
return {
4656
wrapper,

tests/firestore/collection.spec.ts

Lines changed: 37 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,15 @@ import {
99
where,
1010
} from 'firebase/firestore'
1111
import { expectType, setupFirestoreRefs, tds, firestore } from '../utils'
12-
import { computed, nextTick, ref, unref, watch, type Ref } from 'vue'
12+
import {
13+
computed,
14+
nextTick,
15+
ref,
16+
unref,
17+
watch,
18+
type Ref,
19+
defineComponent,
20+
} from 'vue'
1321
import { _RefFirestore } from '../../src/firestore'
1422
import {
1523
useCollection,
@@ -36,17 +44,19 @@ describe(
3644
} = {}) {
3745
let data!: _RefFirestore<VueFirestoreQueryData<T>>
3846

39-
const wrapper = mount({
40-
template: 'no',
41-
setup() {
42-
// @ts-expect-error: generic forced
43-
data =
44-
// split for ts
45-
useCollection(ref, options)
46-
const { data: list, pending, error, promise, stop } = data
47-
return { list, pending, error, promise, stop }
48-
},
49-
})
47+
const wrapper = mount(
48+
defineComponent({
49+
template: 'no',
50+
setup() {
51+
// @ts-expect-error: generic forced
52+
data =
53+
// split for ts
54+
useCollection(ref, options)
55+
const { data: list, pending, error, promise, stop } = data
56+
return { list, pending, error, promise, stop }
57+
},
58+
})
59+
)
5060

5161
return {
5262
wrapper,
@@ -70,19 +80,21 @@ describe(
7080
} = {}) {
7181
let data!: _RefFirestore<VueFirestoreQueryData<T>>
7282

73-
const wrapper = mount({
74-
template: 'no',
75-
setup() {
76-
// @ts-expect-error: generic forced
77-
data = useCollection(
78-
// split for ts
79-
ref,
80-
options
81-
)
82-
const { data: list, pending, error, promise, stop } = data
83-
return { list, pending, error, promise, stop }
84-
},
85-
})
83+
const wrapper = mount(
84+
defineComponent({
85+
template: 'no',
86+
setup() {
87+
// @ts-expect-error: generic forced
88+
data = useCollection(
89+
// split for ts
90+
ref,
91+
options
92+
)
93+
const { data: list, pending, error, promise, stop } = data
94+
return { list, pending, error, promise, stop }
95+
},
96+
})
97+
)
8698

8799
return {
88100
wrapper,

tests/firestore/document.spec.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,14 @@ import {
1414
firestore,
1515
firebaseApp,
1616
} from '../utils'
17-
import { nextTick, ref, shallowRef, unref, type Ref } from 'vue'
17+
import {
18+
nextTick,
19+
ref,
20+
shallowRef,
21+
unref,
22+
type Ref,
23+
defineComponent,
24+
} from 'vue'
1825
import { isPOJO, _MaybeRef, _Nullable } from '../../src/shared'
1926
import {
2027
useDocument,
@@ -43,17 +50,19 @@ describe(
4350
} = {}) {
4451
let data!: _RefFirestore<VueFirestoreDocumentData<T>>
4552

46-
const wrapper = mount({
47-
template: 'no',
48-
setup() {
49-
// @ts-expect-error: stricter type
50-
data =
51-
// split for ts
52-
useDocument(ref, options)
53-
const { data: item, pending, error, promise, stop } = data
54-
return { item, pending, error, promise, stop }
55-
},
56-
})
53+
const wrapper = mount(
54+
defineComponent({
55+
template: 'no',
56+
setup() {
57+
// @ts-expect-error: stricter type
58+
data =
59+
// split for ts
60+
useDocument(ref, options)
61+
const { data: item, pending, error, promise, stop } = data
62+
return { item, pending, error, promise, stop }
63+
},
64+
})
65+
)
5766

5867
return {
5968
wrapper,

tests/firestore/refs-in-collections.spec.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
DocumentData,
77
} from 'firebase/firestore'
88
import { setupFirestoreRefs, sleep } from '../utils'
9-
import { unref } from 'vue'
9+
import { defineComponent, unref } from 'vue'
1010
import { _RefFirestore } from '../../src/firestore'
1111
import {
1212
useCollection,
@@ -28,17 +28,19 @@ describe('Firestore refs in collections', async () => {
2828
} = {}) {
2929
let data!: _RefFirestore<VueFirestoreQueryData<T>>
3030

31-
const wrapper = mount({
32-
template: 'no',
33-
setup() {
34-
// @ts-expect-error: generic forced
35-
data =
36-
// split for ts
37-
useCollection(ref, options)
38-
const { data: list, pending, error, promise, stop } = data
39-
return { list, pending, error, promise, stop }
40-
},
41-
})
31+
const wrapper = mount(
32+
defineComponent({
33+
template: 'no',
34+
setup() {
35+
// @ts-expect-error: generic forced
36+
data =
37+
// split for ts
38+
useCollection(ref, options)
39+
const { data: list, pending, error, promise, stop } = data
40+
return { list, pending, error, promise, stop }
41+
},
42+
})
43+
)
4244

4345
return {
4446
wrapper,

tests/firestore/refs-in-documents.spec.ts

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import {
66
DocumentReference,
77
} from 'firebase/firestore'
88
import { setupFirestoreRefs, sleep } from '../utils'
9-
import { unref } from 'vue'
9+
import { defineComponent, unref } from 'vue'
1010
import { VueFirestoreDocumentData, _RefFirestore } from '../../src/firestore'
1111
import {
1212
UseDocumentOptions,
@@ -28,17 +28,19 @@ describe('Firestore refs in documents', async () => {
2828
} = {}) {
2929
let data!: _RefFirestore<VueFirestoreDocumentData<T>>
3030

31-
const wrapper = mount({
32-
template: 'no',
33-
setup() {
34-
// @ts-expect-error: generic forced
35-
data =
36-
// split for ts
37-
useDocument(ref, options)
38-
const { data: list, pending, error, promise, stop } = data
39-
return { list, pending, error, promise, stop }
40-
},
41-
})
31+
const wrapper = mount(
32+
defineComponent({
33+
template: 'no',
34+
setup() {
35+
// @ts-expect-error: generic forced
36+
data =
37+
// split for ts
38+
useDocument(ref, options)
39+
const { data: list, pending, error, promise, stop } = data
40+
return { list, pending, error, promise, stop }
41+
},
42+
})
43+
)
4244

4345
return {
4446
wrapper,

tests/storage/index.spec.ts

Lines changed: 29 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { mount } from '@vue/test-utils'
22
import { it, describe, expect } from 'vitest'
33
import { uploadString } from 'firebase/storage'
4-
import { nextTick, ref } from 'vue'
4+
import { defineComponent, nextTick, ref } from 'vue'
55
import {
66
useFirebaseStorage,
77
useStorageFileMetadata,
@@ -16,14 +16,16 @@ describe('Storage', () => {
1616
it('generates a URL', async () => {
1717
const objectRef = storageRef('my-url.jpg')
1818
await uploadString(objectRef, 'test', 'raw')
19-
const wrapper = mount({
20-
template: 'no',
21-
setup() {
22-
const { url, promise } = useStorageFileUrl(objectRef)
19+
const wrapper = mount(
20+
defineComponent({
21+
template: 'no',
22+
setup() {
23+
const { url, promise } = useStorageFileUrl(objectRef)
2324

24-
return { url, promise }
25-
},
26-
})
25+
return { url, promise }
26+
},
27+
})
28+
)
2729

2830
await wrapper.vm.promise
2931

@@ -34,14 +36,16 @@ describe('Storage', () => {
3436
it('generates the metadata', async () => {
3537
const objectRef = storageRef('my-url.jpg')
3638
await uploadString(objectRef, 'test', 'raw')
37-
const wrapper = mount({
38-
template: 'no',
39-
setup() {
40-
const { metadata, promise } = useStorageFileMetadata(objectRef)
39+
const wrapper = mount(
40+
defineComponent({
41+
template: 'no',
42+
setup() {
43+
const { metadata, promise } = useStorageFileMetadata(objectRef)
4144

42-
return { metadata, promise }
43-
},
44-
})
45+
return { metadata, promise }
46+
},
47+
})
48+
)
4549

4650
await wrapper.vm.promise
4751

@@ -54,14 +58,17 @@ describe('Storage', () => {
5458
it('can create upload tasks', async () => {
5559
const objectRef = storageRef('my-url.jpg')
5660
await uploadString(objectRef, 'test', 'raw')
57-
const wrapper = mount({
58-
template: 'no',
59-
setup() {
60-
const { uploadTask, upload, uploadProgress } = useStorageFile(objectRef)
61+
const wrapper = mount(
62+
defineComponent({
63+
template: 'no',
64+
setup() {
65+
const { uploadTask, upload, uploadProgress } =
66+
useStorageFile(objectRef)
6167

62-
return { uploadTask, upload, uploadProgress }
63-
},
64-
})
68+
return { uploadTask, upload, uploadProgress }
69+
},
70+
})
71+
)
6572

6673
await nextTick()
6774

tests/vitest-mock-warn.ts

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,12 +107,13 @@ export function mockWarn() {
107107
})
108108
}
109109

110-
declare global {
111-
namespace Vi {
112-
interface JestAssertion<T = any> {
113-
toHaveBeenWarned(): void
114-
toHaveBeenWarnedLast(): void
115-
toHaveBeenWarnedTimes(n: number): void
116-
}
117-
}
110+
interface MockWarnMatcher<R = unknown> {
111+
toHaveBeenWarned(): void
112+
toHaveBeenWarnedLast(): void
113+
toHaveBeenWarnedTimes(n: number): void
114+
}
115+
116+
declare module 'vitest' {
117+
interface Assertion<T = any> extends MockWarnMatcher<T> {}
118+
interface AsymmetricMatchersContaining extends MockWarnMatcher {}
118119
}

0 commit comments

Comments
 (0)