-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoneOfObjectKeys.type.spec.ts
More file actions
106 lines (89 loc) · 3.02 KB
/
oneOfObjectKeys.type.spec.ts
File metadata and controls
106 lines (89 loc) · 3.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import { describe, expect, test } from 'tstyche';
import type * as Vue2_6 from 'vue2-6/types/options';
import type * as Vue2_7 from 'vue2-7/types/options';
import type * as Vue3 from '@vue/runtime-core';
import { oneOfObjectKeysProp } from '../../src/prop-types/oneOfObjectKeys';
import { createVue2Component } from '../utils';
import type { Vue2ComponentWithProp } from '../utils';
const options = { a: 'a', b: 'b', c: 'c' };
type Options = 'a' | 'b' | 'c';
describe('oneOfObjectKeysProp().optional', () => {
test('Vue 2.6', () => {
expect<Vue2_6.PropOptions<Options | undefined>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).optional,
);
expect(
createVue2Component(oneOfObjectKeysProp(options).optional),
).type.toBe<Vue2ComponentWithProp<Options | undefined>>();
});
test('Vue 2.7', () => {
expect<Vue2_7.PropOptions<Options | undefined>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).optional,
);
});
test('Vue 3', () => {
expect<Vue3.Prop<Options | undefined>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).optional,
);
});
});
describe('oneOfObjectKeysProp().nullable', () => {
test('Vue 2.6', () => {
expect<Vue2_6.PropOptions<Options | null>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).nullable,
);
expect(
createVue2Component(oneOfObjectKeysProp(options).nullable),
).type.toBe<Vue2ComponentWithProp<Options | null>>();
});
test('Vue 2.7', () => {
expect<Vue2_7.PropOptions<Options | null>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).nullable,
);
});
test('Vue 3', () => {
expect<Vue3.Prop<Options | null>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).nullable,
);
});
});
describe('oneOfObjectKeysProp().withDefault', () => {
test('Vue 2.6', () => {
expect<Vue2_6.PropOptions<Options>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).withDefault('a'),
);
expect(
createVue2Component(oneOfObjectKeysProp(options).withDefault('a')),
).type.toBe<Vue2ComponentWithProp<Options>>();
});
test('Vue 2.7', () => {
expect<Vue2_7.PropOptions<Options>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).withDefault('a'),
);
});
test('Vue 3', () => {
expect<Vue3.Prop<Options>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).withDefault('a'),
);
});
});
describe('oneOfObjectKeysProp().required', () => {
test('Vue 2.6', () => {
expect<Vue2_6.PropOptions<Options>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).required,
);
expect(
createVue2Component(oneOfObjectKeysProp(options).required),
).type.toBe<Vue2ComponentWithProp<Options>>();
});
test('Vue 2.7', () => {
expect<Vue2_7.PropOptions<Options>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).required,
);
});
test('Vue 3', () => {
expect<Vue3.Prop<Options>>().type.toBeAssignableWith(
oneOfObjectKeysProp(options).required,
);
});
});