|
1 |
| -import { JsonURL } from "../src/JsonURL.js"; |
| 1 | +/* |
| 2 | + MIT License |
| 3 | +
|
| 4 | + Copyright (c) 2022 Leonard Crestez, David MacCormack |
| 5 | +
|
| 6 | + Permission is hereby granted, free of charge, to any person obtaining a copy |
| 7 | + of this software and associated documentation files (the "Software"), to deal |
| 8 | + in the Software without restriction, including without limitation the rights |
| 9 | + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
| 10 | + copies of the Software, and to permit persons to whom the Software is |
| 11 | + furnished to do so, subject to the following conditions: |
2 | 12 |
|
3 |
| -test("aqf implied array e empty", function () { |
4 |
| - expect(JsonURL.parse("e,!e", { AQF: true, impliedArray: [] })).toStrictEqual( |
5 |
| - ["e", ""]) |
6 |
| -}) |
7 |
| -test("aqf implied array empty e", function () { |
8 |
| - expect(JsonURL.parse("!e,e", { AQF: true, impliedArray: [] })).toStrictEqual(["", "e"]); |
9 |
| -}) |
10 |
| -test("aqf explicit array e empty", function () { |
11 |
| - expect(JsonURL.parse("(e,!e)", { AQF: true })).toStrictEqual( |
12 |
| - ["e", ""]); |
13 |
| -}) |
| 13 | + The above copyright notice and this permission notice shall be included in all |
| 14 | + copies or substantial portions of the Software. |
| 15 | +
|
| 16 | + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| 17 | + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| 18 | + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| 19 | + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| 20 | + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
| 21 | + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
| 22 | + SOFTWARE. |
| 23 | +*/ |
| 24 | + |
| 25 | +import { JsonURL } from "../src/JsonURL.js"; |
14 | 26 |
|
15 |
| -test("aqf implied dict e:empty", function () { |
16 |
| - expect(JsonURL.parse("e:!e", { AQF: true, impliedObject: {} })).toStrictEqual( |
17 |
| - { "e": "" }); |
18 |
| -}) |
19 |
| -test("aqf explicit dict e:empty", function () { |
20 |
| - expect(JsonURL.parse("(e:!e)", { AQF: true })).toStrictEqual( |
21 |
| - { "e": "" }); |
22 |
| -}) |
23 |
| -test("aqf implied dict empty:e", function () { |
24 |
| - expect(JsonURL.parse("!e:e", { AQF: true, impliedObject: {} })).toStrictEqual( |
25 |
| - { "": "e" }) |
26 |
| -}) |
27 |
| -test("aqf implied dict e:empty a:b", function () { |
28 |
| - expect(JsonURL.parse("e:!e,a:b", { AQF: true, impliedObject: {} })).toStrictEqual( |
29 |
| - { "e": "", "a": "b" }); |
30 |
| -}) |
| 27 | +test.each([ |
| 28 | + ["e,!e", { AQF: true, impliedArray: [] }, ["e", ""]], |
| 29 | + ["e,false", { AQF: true, impliedArray: [] }, ["e", false]], |
| 30 | + ["!e,e", { AQF: true, impliedArray: [] }, ["", "e"]], |
| 31 | + ["e:!e", { AQF: true, impliedObject: {} }, { e: "" }], |
| 32 | + ["e:false", { AQF: true, impliedObject: {} }, { e: false }], |
| 33 | + ["!e:e", { AQF: true, impliedObject: {} }, { "": "e" }], |
| 34 | + ["e:!e,a:b", { AQF: true, impliedObject: {} }, { e: "", a: "b" }], |
| 35 | + ["(e,!e)", { AQF: true }, ["e", ""]], |
| 36 | + ["(e,false)", { AQF: true }, ["e", false]], |
| 37 | + ["(e:!e)", { AQF: true }, { e: "" }], |
| 38 | + ["(e:false)", { AQF: true }, { e: false }], |
| 39 | +])("JsonURL.parse(%p, %p)", (text, options, expected) => { |
| 40 | + expect(JsonURL.parse(text, options)).toStrictEqual(expected); |
| 41 | +}); |
0 commit comments