-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgetTypeVariant.test.ts
More file actions
46 lines (37 loc) · 2.14 KB
/
Copy pathgetTypeVariant.test.ts
File metadata and controls
46 lines (37 loc) · 2.14 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
import { describe, expect, it } from 'vitest';
import { getTypeVariant, DataTypeVariant } from '../src/extraction/getTypeVariant';
import { DATA_TYPES } from "./data";
describe('getTypeVariant', () => {
it('sollte PRIMITIVE für einfache Typen zurückgeben', () => {
expect(getTypeVariant("string", DATA_TYPES)).toBe(DataTypeVariant.PRIMITIVE);
expect(getTypeVariant("number", DATA_TYPES)).toBe(DataTypeVariant.PRIMITIVE);
expect(getTypeVariant("boolean", DATA_TYPES)).toBe(DataTypeVariant.PRIMITIVE);
});
it('sollte ARRAY für Array-Typen zurückgeben', () => {
expect(getTypeVariant("string[]", DATA_TYPES)).toBe(DataTypeVariant.ARRAY);
expect(getTypeVariant("Array<number>", DATA_TYPES)).toBe(DataTypeVariant.ARRAY);
});
it('sollte OBJECT für Interfaces oder Objekte mit Properties zurückgeben', () => {
expect(getTypeVariant("{ name: string }", DATA_TYPES)).toBe(DataTypeVariant.OBJECT);
});
it('sollte TYPE für einfache Type-Aliase oder void zurückgeben', () => {
expect(getTypeVariant("void", DATA_TYPES)).toBe(DataTypeVariant.TYPE);
expect(getTypeVariant("any", DATA_TYPES)).toBe(DataTypeVariant.TYPE);
});
it('sollte LIST (NUMBER) als ARRAY erkennen (wenn in DATA_TYPES definiert)', () => {
// In data.ts ist LIST als T[] definiert
expect(getTypeVariant("LIST<NUMBER>", DATA_TYPES)).toBe(DataTypeVariant.ARRAY);
});
it('sollte NODE für Funktionstypen wie CONSUMER zurückgeben', () => {
// In data.ts ist CONSUMER als (item:R) => void definiert
expect(getTypeVariant("CONSUMER<NUMBER>", DATA_TYPES)).toBe(DataTypeVariant.NODE);
});
it('sollte NODE für Funktionstypen wie RUNNABLE zurückgeben', () => {
// In data.ts ist CONSUMER als (item:R) => void definiert
expect(getTypeVariant("RUNNABLE", DATA_TYPES)).toBe(DataTypeVariant.NODE);
});
it('sollte NODE für Funktionstypen wie PREDICATE zurückgeben', () => {
// In data.ts ist CONSUMER als (item:R) => void definiert
expect(getTypeVariant("PREDICATE<NUMBER, BOOLEAN>", DATA_TYPES)).toBe(DataTypeVariant.NODE);
});
});