@dungarees/core 0.11.5 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -441
- package/url.d.ts +0 -1
- package/util.d.ts +1 -1
- package/util.js +0 -1
- package/error.test.d.ts +0 -1
- package/error.test.js +0 -72
- package/event.test.d.ts +0 -1
- package/event.test.js +0 -22
- package/fake.test.d.ts +0 -1
- package/fake.test.js +0 -61
- package/marbles-vitest.test.d.ts +0 -1
- package/marbles-vitest.test.js +0 -116
- package/marbles.test.d.ts +0 -1
- package/marbles.test.js +0 -36
- package/type-util.test.d.ts +0 -1
- package/type-util.test.js +0 -147
- package/url.test.d.ts +0 -1
- package/url.test.js +0 -48
- package/util.test.d.ts +0 -1
- package/util.test.js +0 -419
package/fake.test.js
DELETED
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
import { addErrorMethodsToFake } from './fake.js';
|
|
2
|
-
import { coreMarbles } from '@dungarees/core/marbles-vitest.ts';
|
|
3
|
-
import { of } from 'rxjs';
|
|
4
|
-
import { expect, test } from 'vitest';
|
|
5
|
-
test('Create the original if args are empty', () => {
|
|
6
|
-
const originalFake = () => ({ method: () => 1 });
|
|
7
|
-
const fakeCreator = addErrorMethodsToFake(originalFake);
|
|
8
|
-
const fake = fakeCreator();
|
|
9
|
-
expect(fake.method).not.toThrow();
|
|
10
|
-
});
|
|
11
|
-
test('Create sync throwing function', () => {
|
|
12
|
-
const originalFake = () => ({ method: () => 1 });
|
|
13
|
-
const fakeCreator = addErrorMethodsToFake(originalFake);
|
|
14
|
-
const error = new Error('test error');
|
|
15
|
-
const fake = fakeCreator({ method: { type: 'sync', error } });
|
|
16
|
-
expect(fake.method).toThrow(error);
|
|
17
|
-
});
|
|
18
|
-
test('Create multiple sync throwing function', () => {
|
|
19
|
-
const originalFake = () => ({ method: () => 1, method2: () => 2 });
|
|
20
|
-
const fakeCreator = addErrorMethodsToFake(originalFake);
|
|
21
|
-
const error = new Error('test error');
|
|
22
|
-
const error2 = new Error('test error2');
|
|
23
|
-
const fake = fakeCreator({
|
|
24
|
-
method: { type: 'sync', error },
|
|
25
|
-
method2: { type: 'sync', error: error2 },
|
|
26
|
-
});
|
|
27
|
-
expect(fake.method).toThrow(error);
|
|
28
|
-
expect(fake.method2).toThrow(error2);
|
|
29
|
-
});
|
|
30
|
-
test('Create async throwing function', async () => {
|
|
31
|
-
const originalFake = () => ({ method: async () => 1 });
|
|
32
|
-
const fakeCreator = addErrorMethodsToFake(originalFake);
|
|
33
|
-
const error = new Error('test error');
|
|
34
|
-
const fake = fakeCreator({ method: { type: 'async', error } });
|
|
35
|
-
await expect(fake.method).rejects.toEqual(error);
|
|
36
|
-
});
|
|
37
|
-
test('Create observable throwing function', coreMarbles((m) => {
|
|
38
|
-
const originalFake = () => ({ method: () => of(1) });
|
|
39
|
-
const fakeCreator = addErrorMethodsToFake(originalFake);
|
|
40
|
-
const error = new Error('test error');
|
|
41
|
-
const fake = fakeCreator({ method: { type: 'observable', error } });
|
|
42
|
-
m.expect(fake.method()).toBeObservable('-#', {}, error);
|
|
43
|
-
}));
|
|
44
|
-
test('Forwarding constructor paramters', () => {
|
|
45
|
-
const originalFake = (num1, num2) => ({
|
|
46
|
-
method: () => num1,
|
|
47
|
-
method2: () => num2,
|
|
48
|
-
});
|
|
49
|
-
const fakeCreator = addErrorMethodsToFake(originalFake);
|
|
50
|
-
const fake = fakeCreator({}, 1, 2);
|
|
51
|
-
expect(fake.method()).toBe(1);
|
|
52
|
-
expect(fake.method2()).toBe(2);
|
|
53
|
-
});
|
|
54
|
-
test('A throwing method stays callable with the arguments the original took', () => {
|
|
55
|
-
const originalFake = () => ({ method: (_, count) => count });
|
|
56
|
-
const fakeCreator = addErrorMethodsToFake(originalFake);
|
|
57
|
-
expect(fakeCreator().method('a', 1)).toBe(1);
|
|
58
|
-
const error = new Error('boom');
|
|
59
|
-
const fake = fakeCreator({ method: { type: 'sync', error } });
|
|
60
|
-
expect(() => fake.method('a', 1)).toThrow(error);
|
|
61
|
-
});
|
package/marbles-vitest.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/marbles-vitest.test.js
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
import { configure, coreMarbles, mtest } from './marbles-vitest.js';
|
|
2
|
-
import { Subject } from 'rxjs';
|
|
3
|
-
import { expect, test } from 'vitest';
|
|
4
|
-
test('it should run a single marble', coreMarbles(({ expect, cold }) => {
|
|
5
|
-
expect(cold('a')).toBeObservable('a', { a: 'a' });
|
|
6
|
-
}));
|
|
7
|
-
test.each([
|
|
8
|
-
['tf', 'tf'],
|
|
9
|
-
['ft', 'ft'],
|
|
10
|
-
])('it should work with each', coreMarbles(({ expect, coldBoolean }, a, b) => {
|
|
11
|
-
expect(coldBoolean(a)).toBeObservableBoolean(b);
|
|
12
|
-
}));
|
|
13
|
-
mtest.each([
|
|
14
|
-
['tf', 'tf'],
|
|
15
|
-
['ft', 'ft'],
|
|
16
|
-
])('mtest should work with each', ({ expect, coldBoolean }, a, b) => {
|
|
17
|
-
expect(coldBoolean(a)).toBeObservableBoolean(b);
|
|
18
|
-
});
|
|
19
|
-
mtest('it should run without the wrapper', ({ expect, coldBoolean }) => {
|
|
20
|
-
expect(coldBoolean('tf')).toBeObservableBoolean('tf');
|
|
21
|
-
});
|
|
22
|
-
mtest('it should run a single function', ({ expect, coldCall }) => {
|
|
23
|
-
const s = new Subject();
|
|
24
|
-
coldCall('-cc', {
|
|
25
|
-
c: () => {
|
|
26
|
-
s.next('c');
|
|
27
|
-
},
|
|
28
|
-
});
|
|
29
|
-
expect(s).toBeObservable('-cc', { c: 'c' });
|
|
30
|
-
});
|
|
31
|
-
mtest('it should run multiple functions', ({ expect, coldCall }) => {
|
|
32
|
-
const s = new Subject();
|
|
33
|
-
coldCall('-cd', {
|
|
34
|
-
c: () => {
|
|
35
|
-
s.next('c');
|
|
36
|
-
},
|
|
37
|
-
d: () => {
|
|
38
|
-
s.next('d');
|
|
39
|
-
},
|
|
40
|
-
});
|
|
41
|
-
expect(s).toBeObservable('-cd', { c: 'c', d: 'd' });
|
|
42
|
-
});
|
|
43
|
-
mtest('it should create a boolean marble', ({ expect, coldBoolean }) => {
|
|
44
|
-
expect(coldBoolean('tf')).toBeObservable('tf', { t: true, f: false });
|
|
45
|
-
});
|
|
46
|
-
mtest('it should assert a boolean marble', ({ expect, cold }) => {
|
|
47
|
-
expect(cold('tf', { t: true, f: false })).toBeObservableBoolean('tf');
|
|
48
|
-
});
|
|
49
|
-
mtest('it should create a cold marble with a value', ({ expect, coldValue }) => {
|
|
50
|
-
expect(coldValue('-v', true)).toBeObservableBoolean('-t');
|
|
51
|
-
});
|
|
52
|
-
mtest('it should create a cold marble with a value or undefined', ({ expect, coldValueOrUndefined }) => {
|
|
53
|
-
expect(coldValueOrUndefined('-v0', true)).toBeObservable('-t0', {
|
|
54
|
-
t: true,
|
|
55
|
-
'0': undefined,
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
mtest('it should create a cold marble with a value step', ({ expect, coldStep }) => {
|
|
59
|
-
expect(coldStep(true)).toBeObservableBoolean('-t');
|
|
60
|
-
expect(coldStep(true, 2)).toBeObservableBoolean('--t');
|
|
61
|
-
});
|
|
62
|
-
mtest('it should create a cold marble with a value step and close', ({ expect, coldStepAndClose }) => {
|
|
63
|
-
expect(coldStepAndClose(true)).toBeObservableBoolean('-(t|)');
|
|
64
|
-
expect(coldStepAndClose(true, 2)).toBeObservableBoolean('--(t|)');
|
|
65
|
-
});
|
|
66
|
-
mtest('it should create a cold marble with an error', ({ expect, coldError }) => {
|
|
67
|
-
expect(coldError(new Error('test error'))).toBeObservable('-#', {}, new Error('test error'));
|
|
68
|
-
expect(coldError(new Error('test error'), 2)).toBeObservable('--#', {}, new Error('test error'));
|
|
69
|
-
});
|
|
70
|
-
mtest('it should create a cold marble with a value and error', ({ expect, coldStepAndError }) => {
|
|
71
|
-
expect(coldStepAndError(true, new Error('test error'))).toBeObservable('-(t#)', { t: true }, new Error('test error'));
|
|
72
|
-
expect(coldStepAndError(true, new Error('test error'), 2)).toBeObservable('--(t#)', { t: true }, new Error('test error'));
|
|
73
|
-
});
|
|
74
|
-
mtest('it should assert a value marble', ({ expect, coldStep }) => {
|
|
75
|
-
expect(coldStep(true)).toBeObservableValue('-v', true);
|
|
76
|
-
});
|
|
77
|
-
mtest('it should assert a value marble default pattern', ({ expect, coldStep }) => {
|
|
78
|
-
expect(coldStep(true, 0)).toBeObservableValue(true);
|
|
79
|
-
});
|
|
80
|
-
mtest('it should assert a value and close marble', ({ expect, coldStepAndClose }) => {
|
|
81
|
-
expect(coldStepAndClose(true, 0)).toBeObservableValueAndClose(true);
|
|
82
|
-
});
|
|
83
|
-
mtest('it should assert a value and close marble', ({ expect, coldStepAndError }) => {
|
|
84
|
-
expect(coldStepAndError(true, new Error('test error'), 0)).toBeObservableValueAndError(true, new Error('test error'));
|
|
85
|
-
});
|
|
86
|
-
mtest('it should assert a value marble or undefined', ({ expect, coldValueOrUndefined }) => {
|
|
87
|
-
expect(coldValueOrUndefined('-v0', true)).toBeObservableValueOrUndefined('-v0', true);
|
|
88
|
-
});
|
|
89
|
-
mtest('it should assert a step', ({ expect, coldStep }) => {
|
|
90
|
-
expect(coldStep(true)).toBeObservableStep(true);
|
|
91
|
-
expect(coldStep(true, 2)).toBeObservableStep(true, 2);
|
|
92
|
-
});
|
|
93
|
-
mtest('it should assert a step and close', ({ expect, coldStepAndClose }) => {
|
|
94
|
-
expect(coldStepAndClose(true)).toBeObservableStepAndClose(true);
|
|
95
|
-
expect(coldStepAndClose(true, 2)).toBeObservableStepAndClose(true, 2);
|
|
96
|
-
});
|
|
97
|
-
mtest('it should assert an error', ({ expect, coldError }) => {
|
|
98
|
-
expect(coldError(new Error('test error'))).toBeObservableError(new Error('test error'));
|
|
99
|
-
expect(coldError(new Error('test error'), 2)).toBeObservableError(new Error('test error'), 2);
|
|
100
|
-
});
|
|
101
|
-
mtest('it should assert a step with an error', ({ expect, coldStepAndError }) => {
|
|
102
|
-
expect(coldStepAndError(true, new Error('test error'))).toBeObservableStepAndError(true, new Error('test error'));
|
|
103
|
-
expect(coldStepAndError(true, new Error('test error'), 2)).toBeObservableStepAndError(true, new Error('test error'), 2);
|
|
104
|
-
});
|
|
105
|
-
const { cases } = configure({});
|
|
106
|
-
const casesThatRan = [];
|
|
107
|
-
cases('skip and only flags', (_m, { name }) => {
|
|
108
|
-
casesThatRan.push(name);
|
|
109
|
-
}, [
|
|
110
|
-
{ name: 'plain case' },
|
|
111
|
-
{ name: 'case flagged skip', skip: true },
|
|
112
|
-
{ name: 'case with skip false', skip: false },
|
|
113
|
-
]);
|
|
114
|
-
test('cases runs every case except the ones flagged skip', () => {
|
|
115
|
-
expect(casesThatRan).toEqual(['plain case', 'case with skip false']);
|
|
116
|
-
});
|
package/marbles.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/marbles.test.js
DELETED
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { coreMarbles } from '@dungarees/core/marbles.ts';
|
|
2
|
-
import { Subject } from 'rxjs';
|
|
3
|
-
import { test } from 'vitest';
|
|
4
|
-
test('it should run a single function', coreMarbles(({ expect, coldCall }) => {
|
|
5
|
-
const s = new Subject();
|
|
6
|
-
coldCall('-cc', {
|
|
7
|
-
c: () => {
|
|
8
|
-
s.next('c');
|
|
9
|
-
},
|
|
10
|
-
});
|
|
11
|
-
expect(s).toBeObservable('-cc', { c: 'c' });
|
|
12
|
-
}));
|
|
13
|
-
test('it should run multiple functions', coreMarbles(({ expect, coldCall }) => {
|
|
14
|
-
const s = new Subject();
|
|
15
|
-
coldCall('-cd', {
|
|
16
|
-
c: () => {
|
|
17
|
-
s.next('c');
|
|
18
|
-
},
|
|
19
|
-
d: () => {
|
|
20
|
-
s.next('d');
|
|
21
|
-
},
|
|
22
|
-
});
|
|
23
|
-
expect(s).toBeObservable('-cd', { c: 'c', d: 'd' });
|
|
24
|
-
}));
|
|
25
|
-
test('it should create a boolean marble', coreMarbles(({ expect, coldBoolean }) => {
|
|
26
|
-
expect(coldBoolean('tf')).toBeObservable('tf', { t: true, f: false });
|
|
27
|
-
}));
|
|
28
|
-
test('it should assert a boolean marble', coreMarbles(({ expect, cold }) => {
|
|
29
|
-
expect(cold('tf', { t: true, f: false })).toBeObservableBoolean('tf');
|
|
30
|
-
}));
|
|
31
|
-
test.each([
|
|
32
|
-
['tf', 'tf'],
|
|
33
|
-
['ft', 'ft'],
|
|
34
|
-
])('it should work with each', coreMarbles(({ expect, coldBoolean }, a, b) => {
|
|
35
|
-
expect(coldBoolean(a)).toBeObservableBoolean(b);
|
|
36
|
-
}));
|
package/type-util.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/type-util.test.js
DELETED
|
@@ -1,147 +0,0 @@
|
|
|
1
|
-
import { expect, expectTypeOf, test } from 'vitest';
|
|
2
|
-
test('Split<PATH, DELIMITER>', () => {
|
|
3
|
-
expectTypeOf().toEqualTypeOf();
|
|
4
|
-
expectTypeOf().toEqualTypeOf();
|
|
5
|
-
expectTypeOf().toEqualTypeOf();
|
|
6
|
-
});
|
|
7
|
-
test('SplitObjectPath<PATH>', () => {
|
|
8
|
-
expectTypeOf().toEqualTypeOf();
|
|
9
|
-
expectTypeOf().toEqualTypeOf();
|
|
10
|
-
expectTypeOf().toEqualTypeOf();
|
|
11
|
-
});
|
|
12
|
-
test('SplitFilePath<PATH>', () => {
|
|
13
|
-
expectTypeOf().toEqualTypeOf();
|
|
14
|
-
expectTypeOf().toEqualTypeOf();
|
|
15
|
-
expectTypeOf().toEqualTypeOf();
|
|
16
|
-
});
|
|
17
|
-
test('StringLiteral<LITERAL>', () => {
|
|
18
|
-
const literal = 'asd';
|
|
19
|
-
expectTypeOf(literal).toEqualTypeOf();
|
|
20
|
-
// Widened through an annotation rather than an `as` cast, so rule 4 still holds.
|
|
21
|
-
const widened = 'asd';
|
|
22
|
-
// @ts-expect-error it has to be a literal
|
|
23
|
-
const nonLiteral = widened;
|
|
24
|
-
expectTypeOf(nonLiteral).toEqualTypeOf();
|
|
25
|
-
});
|
|
26
|
-
test('ObjectWithStringLiteralKey<KEY, VALUE>', () => {
|
|
27
|
-
const obj = {
|
|
28
|
-
a: 1,
|
|
29
|
-
};
|
|
30
|
-
expectTypeOf(obj).toEqualTypeOf();
|
|
31
|
-
// @ts-expect-error it has to be a literal
|
|
32
|
-
const nonLiteral = {
|
|
33
|
-
a: 1,
|
|
34
|
-
};
|
|
35
|
-
expectTypeOf(nonLiteral).toEqualTypeOf();
|
|
36
|
-
});
|
|
37
|
-
test('JsonType', () => {
|
|
38
|
-
const json = {
|
|
39
|
-
a: 1,
|
|
40
|
-
b: '2',
|
|
41
|
-
c: true,
|
|
42
|
-
d: null,
|
|
43
|
-
e: [1, '2', true, null, [1, '2', true, null]],
|
|
44
|
-
};
|
|
45
|
-
expect(json).toBeDefined();
|
|
46
|
-
// @ts-expect-error it cannot be a function
|
|
47
|
-
const nonJson = {
|
|
48
|
-
f: () => { },
|
|
49
|
-
};
|
|
50
|
-
expect(nonJson).toBeDefined();
|
|
51
|
-
});
|
|
52
|
-
test('TokenNonEmptyString<TOKEN>', () => {
|
|
53
|
-
const token = 'a';
|
|
54
|
-
expectTypeOf(token).toEqualTypeOf();
|
|
55
|
-
// @ts-expect-error it cannot be empty
|
|
56
|
-
const nonToken = '';
|
|
57
|
-
expectTypeOf(nonToken).toEqualTypeOf();
|
|
58
|
-
});
|
|
59
|
-
test('Guard<TYPE>', () => {
|
|
60
|
-
const guard = (arg) => arg === 1;
|
|
61
|
-
expectTypeOf(guard).toEqualTypeOf();
|
|
62
|
-
// @ts-expect-error it has to be a guard
|
|
63
|
-
const nonGuard = (arg) => arg === 1;
|
|
64
|
-
expectTypeOf(nonGuard).toEqualTypeOf();
|
|
65
|
-
});
|
|
66
|
-
test('GetGuarded<GUARD>', () => {
|
|
67
|
-
const testUnused_guard = (arg) => arg === 1;
|
|
68
|
-
expectTypeOf().toEqualTypeOf();
|
|
69
|
-
});
|
|
70
|
-
test('EntryTuples', () => {
|
|
71
|
-
expectTypeOf().toEqualTypeOf();
|
|
72
|
-
expectTypeOf().toEqualTypeOf();
|
|
73
|
-
expectTypeOf().toEqualTypeOf();
|
|
74
|
-
expectTypeOf().toEqualTypeOf();
|
|
75
|
-
});
|
|
76
|
-
test('FilterRecord<RECORD, TYPE>', () => {
|
|
77
|
-
expectTypeOf().toEqualTypeOf();
|
|
78
|
-
});
|
|
79
|
-
test('GetAllPaths<OBJECT>', () => {
|
|
80
|
-
expectTypeOf().toEqualTypeOf();
|
|
81
|
-
});
|
|
82
|
-
test('GetValuesByPath<OBJECT, PATH>', () => {
|
|
83
|
-
expectTypeOf().toEqualTypeOf();
|
|
84
|
-
});
|
|
85
|
-
test('JoinArray<STRINGS, DELIMITER>', () => {
|
|
86
|
-
expectTypeOf().toEqualTypeOf();
|
|
87
|
-
expectTypeOf().toEqualTypeOf();
|
|
88
|
-
});
|
|
89
|
-
test('FromCamelCase<STRING>', () => {
|
|
90
|
-
expectTypeOf().toEqualTypeOf();
|
|
91
|
-
expectTypeOf().toEqualTypeOf();
|
|
92
|
-
expectTypeOf().toEqualTypeOf();
|
|
93
|
-
});
|
|
94
|
-
test('ToCamelCase<STRING[]>', () => {
|
|
95
|
-
expectTypeOf().toEqualTypeOf();
|
|
96
|
-
expectTypeOf().toEqualTypeOf();
|
|
97
|
-
});
|
|
98
|
-
test('FromKebabCase<STRING>', () => {
|
|
99
|
-
expectTypeOf().toEqualTypeOf();
|
|
100
|
-
expectTypeOf().toEqualTypeOf();
|
|
101
|
-
expectTypeOf().toEqualTypeOf();
|
|
102
|
-
});
|
|
103
|
-
test('ToKebabCase<STRING[]>', () => {
|
|
104
|
-
expectTypeOf().toEqualTypeOf();
|
|
105
|
-
expectTypeOf().toEqualTypeOf();
|
|
106
|
-
});
|
|
107
|
-
test('FromSnakeCase<STRING>', () => {
|
|
108
|
-
expectTypeOf().toEqualTypeOf();
|
|
109
|
-
expectTypeOf().toEqualTypeOf();
|
|
110
|
-
expectTypeOf().toEqualTypeOf();
|
|
111
|
-
});
|
|
112
|
-
test('ToSnakeCase<STRING[]>', () => {
|
|
113
|
-
expectTypeOf().toEqualTypeOf();
|
|
114
|
-
expectTypeOf().toEqualTypeOf();
|
|
115
|
-
});
|
|
116
|
-
test('Mutable<TYPE>', () => {
|
|
117
|
-
expectTypeOf().toEqualTypeOf();
|
|
118
|
-
expectTypeOf().toEqualTypeOf();
|
|
119
|
-
});
|
|
120
|
-
test('FlattenIntersection<OBJECT>', () => {
|
|
121
|
-
expectTypeOf().toEqualTypeOf();
|
|
122
|
-
expectTypeOf().toEqualTypeOf();
|
|
123
|
-
});
|
|
124
|
-
test('PartialBesides<OBJECT, KEYS>', () => {
|
|
125
|
-
// Flattened first: PartialBesides produces an intersection, and expectTypeOf compares that
|
|
126
|
-
// by its parts rather than by the object it is equivalent to.
|
|
127
|
-
expectTypeOf().toEqualTypeOf();
|
|
128
|
-
});
|
|
129
|
-
test('DeepPartial<T> - single level', () => {
|
|
130
|
-
expectTypeOf().toEqualTypeOf();
|
|
131
|
-
});
|
|
132
|
-
test('DeepPartial<T> - nested props', () => {
|
|
133
|
-
expectTypeOf().toEqualTypeOf();
|
|
134
|
-
});
|
|
135
|
-
test('SyncFunctionToAsync<FUNC>', () => {
|
|
136
|
-
expectTypeOf().toEqualTypeOf();
|
|
137
|
-
});
|
|
138
|
-
test('SyncFunctionToAsync<FUNC> accepts every function shape', () => {
|
|
139
|
-
expectTypeOf().toEqualTypeOf();
|
|
140
|
-
expectTypeOf().toEqualTypeOf();
|
|
141
|
-
expectTypeOf().toEqualTypeOf();
|
|
142
|
-
});
|
|
143
|
-
test('DetachableMethods<OBJECT>', () => {
|
|
144
|
-
expectTypeOf().toEqualTypeOf();
|
|
145
|
-
expectTypeOf().toEqualTypeOf();
|
|
146
|
-
expectTypeOf().toEqualTypeOf();
|
|
147
|
-
});
|
package/url.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/url.test.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { parseUrl, stringifyUrl } from './url.js';
|
|
2
|
-
import { expect, test } from 'vitest';
|
|
3
|
-
test('stringify full url', () => {
|
|
4
|
-
expect(stringifyUrl({
|
|
5
|
-
protocol: 'https',
|
|
6
|
-
hostname: 'localhost',
|
|
7
|
-
pathname: '/path',
|
|
8
|
-
port: 8080,
|
|
9
|
-
search: {
|
|
10
|
-
a: '1',
|
|
11
|
-
b: '2',
|
|
12
|
-
},
|
|
13
|
-
hash: 'hash',
|
|
14
|
-
})).toBe('https://localhost:8080/path?a=1&b=2#hash');
|
|
15
|
-
});
|
|
16
|
-
test('stringify partial url', () => {
|
|
17
|
-
expect(stringifyUrl({
|
|
18
|
-
protocol: 'https',
|
|
19
|
-
hostname: 'localhost',
|
|
20
|
-
})).toBe('https://localhost/');
|
|
21
|
-
});
|
|
22
|
-
test('parse full url', () => {
|
|
23
|
-
expect(parseUrl('https://localhost:8080/path?a=1&b=2#hash')).toEqual({
|
|
24
|
-
protocol: 'https',
|
|
25
|
-
hostname: 'localhost',
|
|
26
|
-
pathname: '/path',
|
|
27
|
-
port: 8080,
|
|
28
|
-
search: {
|
|
29
|
-
a: '1',
|
|
30
|
-
b: '2',
|
|
31
|
-
},
|
|
32
|
-
hash: 'hash',
|
|
33
|
-
});
|
|
34
|
-
});
|
|
35
|
-
test('parse full url', () => {
|
|
36
|
-
expect(parseUrl('https://localhost/')).toEqual({
|
|
37
|
-
protocol: 'https',
|
|
38
|
-
hostname: 'localhost',
|
|
39
|
-
pathname: '/',
|
|
40
|
-
port: 80,
|
|
41
|
-
search: {},
|
|
42
|
-
hash: '',
|
|
43
|
-
});
|
|
44
|
-
});
|
|
45
|
-
test('Url type', () => {
|
|
46
|
-
const url = 'https://host:8080/path/subpath/?a=1&b=2#hash';
|
|
47
|
-
expect(url).toBe(url);
|
|
48
|
-
});
|
package/util.test.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|