-
Notifications
You must be signed in to change notification settings - Fork 287
/
Copy pathmigrate_legacy_unit_test.ts
42 lines (32 loc) · 1.1 KB
/
migrate_legacy_unit_test.ts
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
import { assertEquals } from "https://deno.land/std@0.208.0/assert/assert_equals.ts"
import { base, bionic, schemasTransformer, vehiclePart } from "./migrate_legacy_unit.ts"
const input = [{
type: "vehicle_part",
storage: 100,
workbench: { mass: 1000, volume: 1000 },
}]
const expected = [{
type: "vehicle_part",
storage: "25 L",
workbench: { mass: "1 kg", volume: "250 L" },
}]
Deno.test("forwards", () => {
const transformer = schemasTransformer([base, vehiclePart])
const result = transformer(input)
assertEquals(result, expected)
})
Deno.test("backwards", () => {
const transformer = schemasTransformer([vehiclePart, base])
const result = transformer(input)
assertEquals(result, expected)
})
Deno.test("even if first doesn't match, it should still match second", () => {
const transformer = schemasTransformer([bionic, vehiclePart, base])
const result = transformer(input)
assertEquals(result, expected)
})
Deno.test("smoke test", () => {
const transformer = schemasTransformer([vehiclePart, bionic, base])
const result = transformer(input)
assertEquals(result, expected)
})