forked from cuelang/lang-js
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Cue.test.js
40 lines (38 loc) · 1.04 KB
/
Cue.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
31
32
33
34
35
36
37
38
39
40
const test = require('tape');
const { Cue } = require('../');
test('Cue', (t) => {
t.test('MarshallJSON', async (assert) => {
const cue = new Cue()
const instance = await cue.compile('test', 'foo: "bar"');
const value = await instance.value();
const json = await value.marshalJSON();
assert.equal(
json,
'{"foo":"bar"}'
);
assert.end();
});
t.test('ToString', async (assert) => {
const cue = new Cue()
const instance = await cue.compile('test', 'foo: "bar"');
const value = await instance.value();
const json = await value.toString();
assert.equal(
json,
`{\n\tfoo: "bar"\n}`
);
assert.end();
});
t.test('Merge', async (assert) => {
const cue = new Cue()
const i0 = await cue.compile('test', 'foo: "bar"');
const i1 = await cue.compile('test', 'bar: "baz"');
const json = await cue.merge(i0, i1).then(i => i.value()).then(v => v.marshalJSON());
assert.equal(
json,
`{"foo":"bar","bar":"baz"}`
);
assert.end();
});
t.end();
});