|
| 1 | +import type { GeneralUtils } from './general-utils' |
1 | 2 | import { ref } from 'vue' |
2 | | -import { createGeneralUtils } from './general-utils' |
3 | 3 |
|
4 | | -describe('key', () => { |
5 | | - const utils = createGeneralUtils<{ a: { b: { c: number } } }>([]) |
| 4 | +describe('GeneralUtils', () => { |
| 5 | + describe('.key', () => { |
| 6 | + const utils = {} as GeneralUtils<{ a: { b: { c: number } } }> |
6 | 7 |
|
7 | | - it('infer correct input type & partial input', () => { |
8 | | - utils.key() |
9 | | - utils.key({}) |
10 | | - utils.key({ type: 'infinite' }) |
11 | | - utils.key({ input: {}, type: 'query' }) |
12 | | - utils.key({ input: {} }) |
13 | | - utils.key({ input: { a: {} } }) |
14 | | - utils.key({ input: { a: { b: {} } } }) |
15 | | - utils.key({ input: { a: { b: { c: 1 } } } }) |
| 8 | + it('infer correct input type & input', () => { |
| 9 | + utils.key() |
| 10 | + utils.key({}) |
| 11 | + utils.key({ input: { a: { b: { c: 1 } } } }) |
16 | 12 |
|
17 | | - utils.key({ type: ref('infinite'), input: { a: ref({ b: ref({ c: 1 }) }) } }) |
| 13 | + // @ts-expect-error invalid input |
| 14 | + utils.key({ input: 123 }) |
| 15 | + // @ts-expect-error invalid input |
| 16 | + utils.key({ input: { a: { b: { c: '1' } } } }) |
18 | 17 |
|
19 | | - // @ts-expect-error invalid input |
20 | | - utils.key({ input: 123 }) |
21 | | - // @ts-expect-error invalid input |
22 | | - utils.key({ input: { a: { b: { c: '1' } } } }) |
| 18 | + // @ts-expect-error not allow ref |
| 19 | + utils.key({ input: { a: { b: ref({ c: 1 }) } } }) |
23 | 20 |
|
24 | | - // @ts-expect-error invalid input |
25 | | - utils.key({ input: ref(123) }) |
26 | | - // @ts-expect-error invalid type |
27 | | - utils.key({ type: ref(123) }) |
28 | | - |
29 | | - // @ts-expect-error invalid input |
30 | | - utils.key({ type: 'ddd' }) |
31 | | - }) |
32 | | - |
33 | | - it('it prevent pass input when type is mutation', () => { |
34 | | - utils.key({ type: 'mutation' }) |
35 | | - // @ts-expect-error input is not allowed when type is mutation |
36 | | - utils.key({ input: {}, type: 'mutation' }) |
37 | | - // @ts-expect-error input is not allowed when type is mutation |
38 | | - utils.key({ input: ref({}), type: 'mutation' }) |
| 21 | + // @ts-expect-error invalid input |
| 22 | + utils.key({ type: 'ddd' }) |
| 23 | + }) |
39 | 24 | }) |
40 | 25 | }) |
0 commit comments