-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathoneOfTypes.type.spec.ts
More file actions
106 lines (89 loc) · 3.04 KB
/
oneOfTypes.type.spec.ts
File metadata and controls
106 lines (89 loc) · 3.04 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 { oneOfTypesProp } from '../../src/prop-types/oneOfTypes';
import { createVue2Component } from '../utils';
import type { Vue2ComponentWithProp } from '../utils';
const options = [Number, String];
type Options = number | string;
describe('oneOfTypesProp().optional', () => {
test('Vue 2.6', () => {
expect<Vue2_6.PropOptions<Options | undefined>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).optional,
);
expect(
createVue2Component(oneOfTypesProp<Options>(options).optional),
).type.toBe<Vue2ComponentWithProp<Options | undefined>>();
});
test('Vue 2.7', () => {
expect<Vue2_7.PropOptions<Options | undefined>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).optional,
);
});
test('Vue 3', () => {
expect<Vue3.Prop<Options | undefined>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).optional,
);
});
});
describe('oneOfTypesProp().nullable', () => {
test('Vue 2.6', () => {
expect<Vue2_6.PropOptions<Options | null>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).nullable,
);
expect(
createVue2Component(oneOfTypesProp<Options>(options).nullable),
).type.toBe<Vue2ComponentWithProp<Options | null>>();
});
test('Vue 2.7', () => {
expect<Vue2_7.PropOptions<Options | null>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).nullable,
);
});
test('Vue 3', () => {
expect<Vue3.Prop<Options | null>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).nullable,
);
});
});
describe('oneOfTypesProp().withDefault', () => {
test('Vue 2.6', () => {
expect<Vue2_6.PropOptions<Options>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).withDefault('a'),
);
expect(
createVue2Component(oneOfTypesProp<Options>(options).withDefault('a')),
).type.toBe<Vue2ComponentWithProp<Options>>();
});
test('Vue 2.7', () => {
expect<Vue2_7.PropOptions<Options>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).withDefault('a'),
);
});
test('Vue 3', () => {
expect<Vue3.Prop<Options>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).withDefault('a'),
);
});
});
describe('oneOfTypesProp().required', () => {
test('Vue 2.6', () => {
expect<Vue2_6.PropOptions<Options>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).required,
);
expect(
createVue2Component(oneOfTypesProp<Options>(options).required),
).type.toBe<Vue2ComponentWithProp<Options>>();
});
test('Vue 2.7', () => {
expect<Vue2_7.PropOptions<Options>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).required,
);
});
test('Vue 3', () => {
expect<Vue3.Prop<Options>>().type.toBeAssignableWith(
oneOfTypesProp<Options>(options).required,
);
});
});