-
Notifications
You must be signed in to change notification settings - Fork 476
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixing issue #52 - fragmentQuery and fragmentURI would cause errors o…
…n undefined fragments (also adding tests)
- Loading branch information
1 parent
695a4b1
commit daadac8
Showing
6 changed files
with
137 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>URI Test Suite</title> | ||
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen"> | ||
<script type="text/javascript" src="../src/punycode.js"></script> | ||
<script type="text/javascript" src="../src/IPv6.js"></script> | ||
<script type="text/javascript" src="../src/SecondLevelDomains.js"></script> | ||
<script type="text/javascript" src="../src/URI.js"></script> | ||
<script type="text/javascript" src="../src/URITemplate.js"></script> | ||
<script type="text/javascript" src="../src/URI.fragmentQuery.js"></script> | ||
<script type="text/javascript" src="../jquery-1.8.2.min.js"></script> | ||
<script type="text/javascript" src="qunit/qunit.js"></script> | ||
|
||
<!-- | ||
as the plugins alter core URI functionality, | ||
it is necessary to re-test URI itself was well | ||
--> | ||
<script type="text/javascript" src="urls.js"></script> | ||
<script type="text/javascript" src="test.js"></script> | ||
<script type="text/javascript" src="test_jim.js"></script> | ||
<script type="text/javascript" src="test_template.js"></script> | ||
<script type="text/javascript" src="test_fragmentQuery.js"></script> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<meta charset="UTF-8" /> | ||
<title>URI Test Suite</title> | ||
<link rel="stylesheet" href="qunit/qunit.css" type="text/css" media="screen"> | ||
<script type="text/javascript" src="../src/punycode.js"></script> | ||
<script type="text/javascript" src="../src/IPv6.js"></script> | ||
<script type="text/javascript" src="../src/SecondLevelDomains.js"></script> | ||
<script type="text/javascript" src="../src/URI.js"></script> | ||
<script type="text/javascript" src="../src/URITemplate.js"></script> | ||
<script type="text/javascript" src="../src/URI.fragmentURI.js"></script> | ||
<script type="text/javascript" src="../jquery-1.8.2.min.js"></script> | ||
<script type="text/javascript" src="qunit/qunit.js"></script> | ||
|
||
<!-- | ||
as the plugins alter core URI functionality, | ||
it is necessary to re-test URI itself was well | ||
--> | ||
<script type="text/javascript" src="urls.js"></script> | ||
<script type="text/javascript" src="test.js"></script> | ||
<script type="text/javascript" src="test_jim.js"></script> | ||
<script type="text/javascript" src="test_template.js"></script> | ||
<script type="text/javascript" src="test_fragmentURI.js"></script> | ||
</head> | ||
<body> | ||
<div id="qunit"></div> | ||
<div id="qunit-fixture"></div> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
(function(){ | ||
|
||
module("URI.fragmentQuery"); | ||
test("storing query-data in fragment", function() { | ||
var u = URI("http://example.org"); | ||
|
||
deepEqual(u.fragment(true), {}, "empty map for missing fragment"); | ||
|
||
u = URI("http://example.org/#"); | ||
deepEqual(u.fragment(true), {}, "empty map for empty fragment"); | ||
|
||
u = URI("http://example.org/#?hello=world"); | ||
deepEqual(u.fragment(true), {hello: "world"}, "reading data object"); | ||
|
||
u.fragment({bar: "foo"}); | ||
deepEqual(u.fragment(true), {bar: "foo"}, "setting data object"); | ||
equal(u.toString(), "http://example.org/#?bar=foo", "setting data object serialized"); | ||
|
||
u.addFragment("name", "value"); | ||
deepEqual(u.fragment(true), {bar: "foo", name: "value"}, "adding value"); | ||
equal(u.toString(), "http://example.org/#?bar=foo&name=value", "adding value serialized"); | ||
|
||
u.removeFragment("bar"); | ||
deepEqual(u.fragment(true), {name: "value"}, "removing value bar"); | ||
equal(u.toString(), "http://example.org/#?name=value", "removing value bar serialized"); | ||
|
||
u.removeFragment("name"); | ||
deepEqual(u.fragment(true), {}, "removing value name"); | ||
equal(u.toString(), "http://example.org/#?", "removing value name serialized"); | ||
}); | ||
|
||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
(function(){ | ||
|
||
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"); | ||
}); | ||
|
||
})(); |