-
-
Notifications
You must be signed in to change notification settings - Fork 515
/
Copy pathComputedDataTemplateStringTest.js
42 lines (39 loc) · 1.32 KB
/
ComputedDataTemplateStringTest.js
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 test from "ava";
import ComputedDataTemplateString from "../src/Data/ComputedDataTemplateString.js";
test("Get fake proxy data", (t) => {
let cd = new ComputedDataTemplateString(["key1", "key2"]);
t.deepEqual(cd.getProxyData(), {
key1: `${cd.prefix}key1${cd.suffix}`,
key2: `${cd.prefix}key2${cd.suffix}`,
});
});
test("Get nested fake proxy data", (t) => {
let cd = new ComputedDataTemplateString(["key1.nested", "key2"]);
t.deepEqual(cd.getProxyData(), {
key1: {
nested: `${cd.prefix}key1.nested${cd.suffix}`,
},
key2: `${cd.prefix}key2${cd.suffix}`,
});
});
test("Get vars from output", (t) => {
let cd = new ComputedDataTemplateString();
t.deepEqual(cd.findVarsInOutput(""), []);
t.deepEqual(cd.findVarsInOutput("slkdjfkljdsf"), []);
t.deepEqual(cd.findVarsInOutput(`slkdjfkljdsf${cd.prefix}${cd.suffix}sldkjflkds`), []);
t.deepEqual(cd.findVarsInOutput(`slkdjfkljdsf${cd.prefix}firstVar${cd.suffix}sldkjflkds`), [
"firstVar",
]);
t.deepEqual(
cd.findVarsInOutput(
`slkdjfkljdsf${cd.prefix}firstVar${cd.suffix}test${cd.prefix}firstVar${cd.suffix}sldkjflkds`
),
["firstVar"]
);
t.deepEqual(
cd.findVarsInOutput(
`slkdjfkljdsf${cd.prefix}firstVar${cd.suffix}test${cd.prefix}secondVar${cd.suffix}sldkjflkds`
),
["firstVar", "secondVar"]
);
});