Skip to content

Commit

Permalink
test: fix types
Browse files Browse the repository at this point in the history
  • Loading branch information
posva committed Feb 19, 2024
1 parent 7d95da0 commit 42b564a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/use-mutation.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ it('types the parameters for the key', () => {
expectTypeOf(one).toBeString()
expectTypeOf(two).toBeNumber()
expectTypeOf(result).toEqualTypeOf<{ name: string }>()
return ['foo']
return [['foo']]
},
})
})
Expand All @@ -17,7 +17,7 @@ it('can return an array of keys', () => {
useMutation({
mutation: () => Promise.resolve(42),
keys() {
return ['one']
return [['one']]
},
})
})
4 changes: 2 additions & 2 deletions src/use-query.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ describe('useQuery', () => {
setup() {
return {
...useQuery<TResult>({
key: 'key',
key: ['key'],
...options,
// @ts-expect-error: generic unmatched but types work
query: query,
Expand Down Expand Up @@ -430,7 +430,7 @@ describe('useQuery', () => {
describe('shared state', () => {
it('reuses the same state for the same key', async () => {
const pinia = createPinia()
mountSimple({ key: 'todos' }, { plugins: [pinia] })
mountSimple({ key: ['todos'] }, { plugins: [pinia] })
mountSimple({ key: ['todos'] }, { plugins: [pinia] })
await runTimers()

Expand Down
14 changes: 7 additions & 7 deletions src/use-query.test-d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ it('infers the data type', () => {
expectTypeOf<Ref<number | undefined>>(
useQuery({
query: () => Promise.resolve(42),
key: 'foo',
key: ['foo'],
}).data
)

expectTypeOf<Ref<{ name: string } | undefined>>(
useQuery({
query: async () => ({ name: 'Edu' }),
key: 'foo',
key: ['foo'],
}).data
)
})
Expand All @@ -22,7 +22,7 @@ it('uses Error by default for the error type', () => {
expectTypeOf<Ref<Error | null>>(
useQuery({
query: async () => 42,
key: 'foo',
key: ['foo'],
}).error
)
})
Expand All @@ -31,7 +31,7 @@ it('can specify the error type', () => {
expectTypeOf<Ref<TypeError | null>>(
useQuery<number, TypeError>({
query: async () => 42,
key: 'foo',
key: ['foo'],
}).error
)
})
Expand All @@ -41,7 +41,7 @@ it('expects an async query', () => {
useQuery({
// @ts-expect-error
query: () => 42,
key: 'foo',
key: ['foo'],
}).data
)

Expand All @@ -51,7 +51,7 @@ it('expects an async query', () => {
query: async () => {
throw new Error('nope')
},
key: 'foo',
key: ['foo'],
}).data
)
})
Expand All @@ -71,7 +71,7 @@ it('can use a function as a key', () => {
it('can use objects in keys', () => {
useQuery({
query: async () => 42,
key: { id: 1 },
key: [{ id: 1 }],
})

useQuery({
Expand Down

0 comments on commit 42b564a

Please sign in to comment.