-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtransform_test.ts
52 lines (47 loc) · 1.13 KB
/
transform_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
43
44
45
46
47
48
49
50
51
52
import { assertEquals } from "https://deno.land/[email protected]/assert/assert_equals.ts";
import { parseFilters, removeUndefined } from "./transform.ts";
Deno.test("parseFilters", () => {
const got = parseFilters(["stack=deploy", "stage=PROD", "app=riff-raff"]);
const want = {
stack: "deploy",
stage: "PROD",
app: "riff-raff",
};
assertEquals(got, want);
});
Deno.test("parseFilters without an = delimiter", () => {
const got = parseFilters(["message"]);
const want = {
message: undefined,
};
assertEquals(got, want);
});
Deno.test("parseFilters without a value on the RHS of =", () => {
const got = parseFilters(["name="]);
const want = {
name: "",
};
assertEquals(got, want);
});
Deno.test("removeUndefined", () => {
const got = removeUndefined({
stack: "deploy",
stage: undefined,
app: "riff-raff",
team: "",
});
const want = {
stack: "deploy",
app: "riff-raff",
};
assertEquals(got, want);
});
Deno.test("removeUndefined where the RHS is 0", () => {
const got = removeUndefined({
errors: "0",
});
const want = {
errors: "0",
};
assertEquals(got, want);
});