diff options
author | Kim Alvefur <zash@zash.se> | 2022-05-08 18:06:41 +0200 |
---|---|---|
committer | Kim Alvefur <zash@zash.se> | 2022-05-08 18:06:41 +0200 |
commit | 1c6747f200505db7900204a9297b97c82c959df1 (patch) | |
tree | b73fc162210693217cefb6c7521224988679f351 /spec | |
parent | 71dc755f0f20c5dd2ad6ed76a8ae791bae16a8b1 (diff) | |
parent | d05af9f2b54d292b49b694d8317152f4339f7076 (diff) | |
download | prosody-1c6747f200505db7900204a9297b97c82c959df1.tar.gz prosody-1c6747f200505db7900204a9297b97c82c959df1.zip |
Merge 0.12->trunk
Diffstat (limited to 'spec')
-rw-r--r-- | spec/util_jsonpointer_spec.lua | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/spec/util_jsonpointer_spec.lua b/spec/util_jsonpointer_spec.lua new file mode 100644 index 00000000..ce07c7a1 --- /dev/null +++ b/spec/util_jsonpointer_spec.lua @@ -0,0 +1,38 @@ +describe("util.jsonpointer", function() + local json, jp; + setup(function() + json = require "util.json"; + jp = require "util.jsonpointer"; + end) + describe("resolve()", function() + local example; + setup(function() + example = json.decode([[{ + "foo": ["bar", "baz"], + "": 0, + "a/b": 1, + "c%d": 2, + "e^f": 3, + "g|h": 4, + "i\\j": 5, + "k\"l": 6, + " ": 7, + "m~n": 8 + }]]) + end) + it("works", function() + assert.same(example, jp.resolve(example, "")); + assert.same({ "bar", "baz" }, jp.resolve(example, "/foo")); + assert.same("bar", jp.resolve(example, "/foo/0")); + assert.same(0, jp.resolve(example, "/")); + assert.same(1, jp.resolve(example, "/a~1b")); + assert.same(2, jp.resolve(example, "/c%d")); + assert.same(3, jp.resolve(example, "/e^f")); + assert.same(4, jp.resolve(example, "/g|h")); + assert.same(5, jp.resolve(example, "/i\\j")); + assert.same(6, jp.resolve(example, "/k\"l")); + assert.same(7, jp.resolve(example, "/ ")); + assert.same(8, jp.resolve(example, "/m~0n")); + end) + end) +end) |