Skip to content

Commit 5475fa6

Browse files
committed
Update transformation.test.ts
1 parent 7a563ef commit 5475fa6

File tree

1 file changed

+8
-46
lines changed

1 file changed

+8
-46
lines changed

packages/url-loader/tests/lib/transformation.test.ts

Lines changed: 8 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import { constructTransformation, promptArrayToString } from './constructTransformation';
1+
import { describe, it, expect } from 'vitest';
2+
import { constructTransformation, promptArrayToString } from '../../src/lib/transformations';
23

34
describe('constructTransformation', () => {
4-
55
it('should construct a transformation string with a prefix, qualifier, and string value', () => {
66
const transformation = constructTransformation({
77
prefix: 'w',
@@ -56,8 +56,8 @@ describe('constructTransformation', () => {
5656

5757
it('should apply converters to the value if the test passes', () => {
5858
const converters = [{
59-
test: (value) => Array.isArray(value),
60-
convert: (value) => value.join(':')
59+
test: (value: any) => Array.isArray(value),
60+
convert: (value: any) => value.join(':')
6161
}];
6262
const transformation = constructTransformation({
6363
qualifier: 'co',
@@ -69,8 +69,8 @@ describe('constructTransformation', () => {
6969

7070
it('should not apply a converter if the test fails', () => {
7171
const converters = [{
72-
test: (value) => Array.isArray(value),
73-
convert: (value) => value.join(':')
72+
test: (value: any) => Array.isArray(value),
73+
convert: (value: any) => value.join(':')
7474
}];
7575
const transformation = constructTransformation({
7676
qualifier: 'w',
@@ -112,49 +112,11 @@ describe('constructTransformation', () => {
112112
});
113113
expect(transformation).toBeUndefined();
114114
});
115-
116-
it('should apply multiple converters in order', () => {
117-
const converters = [
118-
{ test: (v) => typeof v === 'number', convert: (v: number) => v + 1 },
119-
{ test: (v) => typeof v === 'number', convert: (v: number) => v * 2 }
120-
];
121-
const transformation = constructTransformation({
122-
qualifier: 'w',
123-
value: 5,
124-
converters
125-
});
126-
expect(transformation).toBe('w_12'); // (5 + 1) * 2
127-
});
128-
129-
it('should return undefined if value is true but qualifier is missing', () => {
130-
const transformation = constructTransformation({
131-
value: true
132-
});
133-
expect(transformation).toBeUndefined();
134-
});
135-
136-
it('should return undefined if value is null', () => {
137-
const transformation = constructTransformation({
138-
qualifier: 'x',
139-
value: null
140-
});
141-
expect(transformation).toBeUndefined();
142-
});
143115
});
144116

145117
describe('promptArrayToString', () => {
146118
it('should convert an array of strings to a single string with parentheses and semicolons', () => {
147-
const result = promptArrayToString(['hello', 'world', 'test']);
148-
expect(result).toBe('(hello;world;test)');
149-
});
150-
151-
it('should return empty parentheses for an empty array', () => {
152-
const result = promptArrayToString([]);
153-
expect(result).toBe('()');
154-
});
155-
156-
it('should handle array with one element', () => {
157-
const result = promptArrayToString(['single']);
158-
expect(result).toBe('(single)');
119+
const result = promptArrayToString(['hello', 'world']);
120+
expect(result).toBe('(hello;world)');
159121
});
160122
});

0 commit comments

Comments
 (0)