-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
30 lines (26 loc) · 781 Bytes
/
test.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
import test from "ava";
import yaml from "js-yaml";
import type from "./index.js";
const schema = yaml.DEFAULT_SCHEMA.extend([ type ]);
test("test concatenating sequences", t => {
t.deepEqual(yaml.load(`
- &seq1
- qux
- qox
- &seq2
- qix
- qax
- !!concat-seqs
- *seq1
- - foo
- bar
- *seq2
`, { schema }), [["qux", "qox"], ["qix", "qax"], ["qux", "qox", "foo", "bar", "qix", "qax"]]);
});
test("test deep sequences", t => {
t.deepEqual(yaml.load("- &seq1 [[qux, qox]]\n- &seq2 [[qix, qax]]\n- !!concat-seqs [*seq1, [foo, bar], *seq2]", { schema }),
[[["qux", "qox"]], [["qix", "qax"]], [["qux", "qox"], "foo", "bar", ["qix", "qax"]]]);
});
test("test null sequence", t => {
t.deepEqual(yaml.load("- !!concat-seqs", { schema }), [[]]);
});