aboutsummaryrefslogtreecommitdiff
path: root/thirdparty/URI.js/test/test_fragmentURI.js
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2016-10-10 03:47:49 +0200
committerFlorian Dold <florian.dold@gmail.com>2016-10-10 03:47:49 +0200
commit21e6b15991212e21a0bd9928890e8e8518f367e8 (patch)
tree3859320d916ff6c2e2fbe2f022375827fa28997c /thirdparty/URI.js/test/test_fragmentURI.js
parent02fa518542328183f35ae04d389b61226f4c4e30 (diff)
parentd5194154335d6cb30edca9b648083069faf9778c (diff)
downloadwallet-core-21e6b15991212e21a0bd9928890e8e8518f367e8.tar.xz
Merge commit 'd5194154335d6cb30edca9b648083069faf9778c' as 'thirdparty/URI.js'
Diffstat (limited to 'thirdparty/URI.js/test/test_fragmentURI.js')
-rw-r--r--thirdparty/URI.js/test/test_fragmentURI.js61
1 files changed, 61 insertions, 0 deletions
diff --git a/thirdparty/URI.js/test/test_fragmentURI.js b/thirdparty/URI.js/test/test_fragmentURI.js
new file mode 100644
index 000000000..87a28b8e5
--- /dev/null
+++ b/thirdparty/URI.js/test/test_fragmentURI.js
@@ -0,0 +1,61 @@
+(function() {
+ 'use strict';
+ /*global URI, test, equal, ok */
+
+ module('URI.fragmentURI');
+ test('storing URLs in fragment', function() {
+ var u = URI('http://example.org');
+ var f;
+
+ // var uri = URI('http://example.org/#!/foo/bar/baz.html');
+ // var furi = uri.fragment(true);
+ // furi.pathname() === '/foo/bar/baz.html';
+ // furi.pathname('/hello.html');
+ // uri.toString() === 'http://example.org/#!/hello.html'
+
+ ok(u.fragment(true) instanceof URI, 'URI instance for missing fragment');
+
+ u = URI('http://example.org/#');
+ ok(u.fragment(true) instanceof URI, 'URI instance for empty fragment');
+
+ u = URI('http://example.org/#!/foo/bar/baz.html');
+ f = u.fragment(true);
+ equal(f.pathname(), '/foo/bar/baz.html', 'reading path of FragmentURI');
+ equal(f.filename(), 'baz.html', 'reading filename of FragmentURI');
+
+ f.filename('foobar.txt');
+ equal(f.pathname(), '/foo/bar/foobar.txt', 'modifying filename of FragmentURI');
+ equal(u.fragment(), '!/foo/bar/foobar.txt', 'modifying fragment() through FragmentURI on original');
+ equal(u.toString(), 'http://example.org/#!/foo/bar/foobar.txt', 'modifying filename of FragmentURI on original');
+ });
+ test('fragmentPrefix', function() {
+ var u;
+
+ URI.fragmentPrefix = '?';
+ u = URI('http://example.org');
+ equal(u._parts.fragmentPrefix, '?', 'init using global property');
+
+ u.fragment('#!/foo/bar/baz.html');
+ equal(u.fragment(), '!/foo/bar/baz.html', 'unparsed ?');
+ ok(u.fragment(true) instanceof URI, 'parsing ? prefix - is URI');
+ equal(u.fragment(true).toString(), '', 'parsing ? prefix - result');
+
+ u.fragment('#?/foo/bar/baz.html');
+ equal(u.fragment(), '?/foo/bar/baz.html', 'unparsed ?');
+ ok(u.fragment(true) instanceof URI, 'parsing ? prefix - is URI');
+ equal(u.fragment(true).toString(), '/foo/bar/baz.html', 'parsing ? prefix - result');
+
+ u.fragmentPrefix('§');
+ equal(u.fragment(), '?/foo/bar/baz.html', 'unparsed §');
+ ok(u.fragment(true) instanceof URI, 'parsing § prefix - is URI');
+ equal(u.fragment(true).toString(), '', 'parsing § prefix - result');
+
+ u.fragment('#§/foo/bar/baz.html');
+ equal(u.fragment(), '§/foo/bar/baz.html', 'unparsed §');
+ ok(u.fragment(true) instanceof URI, 'parsing § prefix - is URI');
+ equal(u.fragment(true).toString(), '/foo/bar/baz.html', 'parsing § prefix - result');
+
+ URI.fragmentPrefix = '!';
+ });
+
+})(); \ No newline at end of file