From 3dabbbd5325c9fad9582cd44b1da68dece78eaa0 Mon Sep 17 00:00:00 2001 From: Urban Müller Date: Thu, 21 Jun 2018 16:42:32 +0200 Subject: no reason for different naming --- test/U_tests.json | 211 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 211 insertions(+) create mode 100644 test/U_tests.json (limited to 'test/U_tests.json') diff --git a/test/U_tests.json b/test/U_tests.json new file mode 100644 index 0000000..e35ff9d --- /dev/null +++ b/test/U_tests.json @@ -0,0 +1,211 @@ +[ + { + "args": ["/Zürich"], + "exp": "/Z%C3%BCrich", + "name": "U() with utf8 umlaut" + }, + + { + "args": ["/path#Zürich"], + "exp": "/path#Z%C3%BCrich", + "name": "U() with utf8 umlaut in fragment" + }, + + { + "args": ["/foo.html?"], + "exp": "/foo.html", + "name": "U() removes ? at end" + }, + + { + "args": ["/foo.html#"], + "exp": "/foo.html", + "name": "U() removes # at end" + }, + + { + "args": ["/foo.html?#"], + "exp": "/foo.html", + "name": "U() removes ?# at end" + }, + + { + "args": ["/foo.html#?"], + "exp": "/foo.html#?", + "name": "U() keeps #? at end" + }, + + { + "args": ["/foo.html", {"bar": null}], + "exp": "/foo.html", + "name": "U() empty parameter removed" + }, + + { + "args": ["/foo.html?bar="], + "exp": "/foo.html?bar=", + "name": "U() keep empty parameter with = if only base is given" + }, + + { + "args": ["/foo.html?foo=bar&qux"], + "exp": "/foo.html?foo=bar&qux", + "name": "U() keep empty parameter without = if only base is given" + }, + + { + "args": ["/foo.html?bar=", {"foo": "gna"}], + "exp": "/foo.html?foo=gna", + "name": "U() empty parameter with = removed if parameters get changed" + }, + + { + "args": ["/foo.html?foo=bar&qux", {"gna": "gnaber"}], + "exp": "/foo.html?foo=bar&gna=gnaber", + "name": "U() empty parameter without = removed if parameters get changed" + }, + + { + "args": ["/foo.html?bar=gna&foo=g", {"bar": ""}], + "exp": "/foo.html?foo=g", + "name": "U() remove parameter in base by overwriting with empty string" + }, + + { + "args": ["/foo.html?bar=gna&foo=g", {"bar": false}], + "exp": "/foo.html?foo=g", + "name": "U() remove parameter in base by overwriting with false" + }, + + { + "args": ["/foo.html?bar=gna&foo=g", {"bar": null}], + "exp": "/foo.html?bar=gna&foo=g", + "name": "U() keep parameter in base instead of overwriting with null" + }, + + { + "args": ["/foo.html", {"bar": {"gna": 42, "qux": {"quux": "", "gnöp": "fasel"}}}], + "exp": "/foo.html?bar%5Bgna%5D=42&bar%5Bqux%5D%5Bquux%5D=%3CZ%C3%BCrich%3E&bar%5Bqux%5D%5Bgn%C3%B6p%5D=fasel", + "name": "U() with nested arrays" + }, + + { + "args": ["/foo.html?", {"foo" : "bar[qux][gnöp]=fasel"}], + "exp": "/foo.html?foo=bar%5Bqux%5D%5Bgn%C3%B6p%5D%3Dfasel", + "name": "U() with array syntax in value and ? at end of base" + }, + + { + "args": ["/foo.html?a=b&bar=qux&c=d", {"bar": "baz"}], + "exp": "/foo.html?a=b&bar=baz&c=d", + "name": "U() args override get params in base url" + }, + + { + "args": ["/foo.html?a=b&bar=qux&c=d", {"bar": "baz", "gna": "gnaber"}], + "exp": "/foo.html?a=b&bar=baz&c=d&gna=gnaber", + "name": "U() args override get params in base url and appends remaining params" + }, + + { + "args": ["/foo.html?gna=g&a=b&bar=qux&c=d", {"bar": "baz", "gna": "gnaber"}], + "exp": "/foo.html?gna=gnaber&a=b&bar=baz&c=d", + "name": "U() args override get params in base url keeping same order" + }, + + { + "args": ["/foo.html?bar.qux=a.b", {"c.d": "e.f", "g h": "i j"}], + "exp": "/foo.html?bar.qux=a.b&c.d=e.f&g+h=i+j", + "name": "U() dots and spaces in arg names are preserved" + }, + + { + "args": ["/foo.html?bar=a+b+c", {"foo": "d e f"}], + "exp": "/foo.html?bar=a+b+c&foo=d+e+f", + "name": "U() handles multiple spaces in parameter values" + }, + + { + "args": ["/foo.html?bar=qux#frag=frog", {"baz": "gna"}], + "exp": "/foo.html?bar=qux&baz=gna#frag=frog", + "name": "U() fragment after params" + }, + + { + "args": ["Jet d'eau"], + "exp": "Jet%20d%27eau", + "name": "U() with single quotes in URL" + }, + + { + "args": ["/test.html?foo=bar?qux=gna", {"?q": "?r"}], + "exp": "/test.html?foo=bar%3Fqux%3Dgna&%3Fq=%3Fr", + "name": "U() quoting of ? in args but not base" + }, + + { + "args": ["%% %1%x %1x%x1%xx%11%ff%FF%0f%0F %"], + "exp": "%25%25%20%251%25x%20%251x%25x1%25xx%11%ff%FF%0f%0F%20%25", + "name": "U() quoting of % if not followed by 2 hex digits" + }, + + { + "args": ["path#%% %1%x %1x%x1%xx%11%ff%FF%0f%0F %"], + "exp": "path#%25%25%20%251%25x%20%251x%25x1%25xx%11%ff%FF%0f%0F%20%25", + "name": "U() quoting of % if not followed by 2 hex digits in fragment" + }, + + { + "args": ["a\\b"], + "exp": "a/b", + "name": "U() converting of \\ to /" + }, + + { + "args": ["path/#a\\b"], + "exp": "path/#a%5Cb", + "name": "U() encode \\ in fragment" + }, + + { + "args": ["foo.html?bar=\\gna"], + "exp": "foo.html?bar=%5Cgna", + "name": "U() encode \\ in url parameter" + }, + + { + "args": ["path/#?a=b"], + "exp": "path/#?a=b", + "name": "U() keep query syntax in fragment" + }, + + { + "args": ["path/#Jet d'eau"], + "exp": "path/#Jet%20d%27eau", + "name": "U() with single quotes in fragment" + }, + + { + "args": ["//gna.ch"], + "exp": "//gna.ch/", + "name": "U() add / for absolute url without path" + }, + + { + "args": ["http://gna.ch"], + "exp": "http://gna.ch/", + "name": "U() add / for absolute http url without path" + }, + + { + "args": ["app://settings"], + "exp": "app://settings", + "name": "U() do not add / for non-http url without path" + }, + + { + "args": ["/foo.html", {"": {"": "ham"}}], + "exp": "/foo.html?%3Cspam%3E%5B%3Cspam%3E%5D=ham", + "name": "U() urlencode keys of nested structures" + } +] -- cgit v1.2.3