Skip to content

Commit 7a5430f

Browse files
committed
test(ts): add remaining type tests
Signed-off-by: Lexus Drumgold <unicornware@flexdevelopment.llc>
1 parent 3120990 commit 7a5430f

File tree

3 files changed

+138
-0
lines changed

3 files changed

+138
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
/**
2+
* @file Unit Tests - ResolveAliasOptions
3+
* @module mlly/interfaces/tests/unit-d/ResolveAliasOptions
4+
*/
5+
6+
import type { OneOrMany } from '@flex-development/tutils'
7+
import type TestSubject from '../options-resolve-alias'
8+
9+
describe('unit-d:interfaces/ResolveAliasOptions', () => {
10+
it('should match [baseUrl?: string]', () => {
11+
expectTypeOf<TestSubject>()
12+
.toHaveProperty('baseUrl')
13+
.toEqualTypeOf<string | undefined>()
14+
})
15+
16+
it('should match [extensions?: string[] | readonly string[]]', () => {
17+
expectTypeOf<TestSubject>()
18+
.toHaveProperty('extensions')
19+
.toEqualTypeOf<string[] | readonly string[] | undefined>()
20+
})
21+
22+
it('should match [fileExists?(this: void, path: string): boolean]', () => {
23+
expectTypeOf<TestSubject>()
24+
.toHaveProperty('fileExists')
25+
.toEqualTypeOf<((this: void, path: string) => boolean) | undefined>()
26+
})
27+
28+
it('should match [mainFields?: OneOrMany<string>[]]', () => {
29+
expectTypeOf<TestSubject>()
30+
.toHaveProperty('mainFields')
31+
.toEqualTypeOf<OneOrMany<string>[] | undefined>()
32+
})
33+
34+
it('should match [parent?: string]', () => {
35+
expectTypeOf<TestSubject>()
36+
.toHaveProperty('parent')
37+
.toEqualTypeOf<string | undefined>()
38+
})
39+
40+
it('should match [paths?: Record<string, string[]>]', () => {
41+
expectTypeOf<TestSubject>()
42+
.toHaveProperty('paths')
43+
.toEqualTypeOf<Record<string, string[]> | undefined>()
44+
})
45+
46+
it('should match [readFile?(this: void, filename: string): string]', () => {
47+
expectTypeOf<TestSubject>()
48+
.toHaveProperty('readFile')
49+
.toEqualTypeOf<((this: void, filename: string) => string) | undefined>()
50+
})
51+
52+
it('should match [tsconfig?: string]', () => {
53+
expectTypeOf<TestSubject>()
54+
.toHaveProperty('tsconfig')
55+
.toEqualTypeOf<string | undefined>()
56+
})
57+
})
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/**
2+
* @file Unit Tests - ResolveOptions
3+
* @module mlly/interfaces/tests/unit-d/ResolveOptions
4+
*/
5+
6+
import type { ModuleSpecifierType } from '#src/types'
7+
import type { Ext } from '@flex-development/pathe'
8+
import type { EmptyString } from '@flex-development/tutils'
9+
import type TestSubject from '../options-resolve'
10+
11+
describe('unit-d:interfaces/ResolveOptions', () => {
12+
it('should match [conditions?: Set<string> | string[] | readonly string[]]', () => {
13+
expectTypeOf<TestSubject>()
14+
.toHaveProperty('conditions')
15+
.toEqualTypeOf<Set<string> | string[] | readonly string[] | undefined>()
16+
})
17+
18+
it('should match [ext?: Ext | Function | false]', () => {
19+
expectTypeOf<TestSubject>()
20+
.toHaveProperty('ext')
21+
.toEqualTypeOf<
22+
| Ext
23+
| false
24+
| ((
25+
specifier: string,
26+
resolved: string
27+
) => EmptyString | Ext | PromiseLike<EmptyString | Ext>)
28+
| undefined
29+
>()
30+
})
31+
32+
it('should match [extensions?: string[] | readonly string[]]', () => {
33+
expectTypeOf<TestSubject>()
34+
.toHaveProperty('extensions')
35+
.toEqualTypeOf<string[] | readonly string[] | undefined>()
36+
})
37+
38+
it('should match [parent?: URL | string]', () => {
39+
expectTypeOf<TestSubject>()
40+
.toHaveProperty('parent')
41+
.toEqualTypeOf<URL | string | undefined>()
42+
})
43+
44+
it('should match [preserveSymlinks?: boolean]', () => {
45+
expectTypeOf<TestSubject>()
46+
.toHaveProperty('preserveSymlinks')
47+
.toEqualTypeOf<boolean | undefined>()
48+
})
49+
50+
it('should match [type?: Function | ModuleSpecifierType]', () => {
51+
expectTypeOf<TestSubject>()
52+
.toHaveProperty('type')
53+
.toEqualTypeOf<
54+
| ModuleSpecifierType
55+
| ((
56+
resolved: string
57+
) => ModuleSpecifierType | PromiseLike<ModuleSpecifierType>)
58+
| undefined
59+
>()
60+
})
61+
})
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
/**
2+
* @file Unit Tests - MIMEType
3+
* @module mlly/types/tests/unit-d/MIMEType
4+
*/
5+
6+
import type TestSubject from '../mime-type'
7+
8+
describe('unit-d:types/MIMEType', () => {
9+
it('should extract "application/json"', () => {
10+
expectTypeOf<TestSubject>().extract<'application/json'>().toBeString()
11+
})
12+
13+
it('should extract "application/wasm"', () => {
14+
expectTypeOf<TestSubject>().extract<'application/wasm'>().toBeString()
15+
})
16+
17+
it('should extract "text/javascript"', () => {
18+
expectTypeOf<TestSubject>().extract<'text/javascript'>().toBeString()
19+
})
20+
})

0 commit comments

Comments
 (0)