diff options
Diffstat (limited to 'std/encoding/yaml/parse_test.ts')
-rw-r--r-- | std/encoding/yaml/parse_test.ts | 54 |
1 files changed, 43 insertions, 11 deletions
diff --git a/std/encoding/yaml/parse_test.ts b/std/encoding/yaml/parse_test.ts index 029665e44..ec1b386f9 100644 --- a/std/encoding/yaml/parse_test.ts +++ b/std/encoding/yaml/parse_test.ts @@ -3,23 +3,55 @@ // Copyright 2011-2015 by Vitaly Puzrin. All rights reserved. MIT license. // Copyright 2018-2019 the Deno authors. All rights reserved. MIT license. -import { parse } from "./parse.ts"; +import { parse, parseAll } from "./parse.ts"; import { test } from "../../testing/mod.ts"; import { assertEquals } from "../../testing/asserts.ts"; test({ - name: "parsed correctly", + name: "`parse` parses single document yaml string", fn(): void { - const FIXTURE = ` - test: toto - foo: - bar: True - baz: 1 - qux: ~ - `; + const yaml = ` + test: toto + foo: + bar: True + baz: 1 + qux: ~ + `; - const ASSERTS = { test: "toto", foo: { bar: true, baz: 1, qux: null } }; + const expected = { test: "toto", foo: { bar: true, baz: 1, qux: null } }; - assertEquals(parse(FIXTURE), ASSERTS); + assertEquals(parse(yaml), expected); + } +}); + +test({ + name: "`parseAll` parses the yaml string with multiple documents", + fn(): void { + const yaml = ` +--- +id: 1 +name: Alice +--- +id: 2 +name: Bob +--- +id: 3 +name: Eve + `; + const expected = [ + { + id: 1, + name: "Alice" + }, + { + id: 2, + name: "Bob" + }, + { + id: 3, + name: "Eve" + } + ]; + assertEquals(parseAll(yaml), expected); } }); |