-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtests.html
63 lines (57 loc) · 2.3 KB
/
tests.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<html>
<head>
<title>ChromeTorrent tests</title>
<link rel="stylesheet" href="qunit.css" type="text/css" media="screen" charset="utf-8">
<script type="text/javascript" charset="utf-8" src="jquery-1.5.min.js">
</script>
<script type="text/javascript" charset="utf-8" src="qunit.js">
</script>
<script type="text/javascript" charset="utf-8" src="chrometorrent.js">
</script>
<script type="text/javascript" charset="utf-8">
$().ready(function()
{
test("When a ChromeTorrent is created ", function() {
$.ajax = function(settings) {
settings.success("<html><div id='token' style='display:none;'>fakeToken</div></html>", 200);
};
var l = makeLog();
var torrent = new ChromeTorrent(l);
torrent.addTorrent("");
ok(torrent != null, "it is initialized without error");
equals(torrent.getUser(), "user", "it has a user");
equals(torrent.getHost(), "host", "it has a host");
equals(torrent.getPassword(), "password", "it has a password");
equals(torrent.getToken(), "fakeToken", "it fetches a torrent from the host");
});
});
test("A ChromeTorrent can", function() {
$.ajax = function(settings) {
settings.success("<html><div id='token' style='display:none;'>fakeToken</div></html>", 200);
};
var torrent = new ChromeTorrent("host", "user", "password");
equals(torrent.createDownloadUrlForTorrent("torrent"), "host?token=fakeToken&action=add-url&s=torrent", "construct the url for starting a download for a torrent" );
var getUrl = "";
var password = "";
var username = "";
$.ajax = function(settings) {
getUrl = settings.url;
password = settings.password;
username = settings.username;
};
torrent.addTorrent("myTorrent");
equals(getUrl, "host?token=fakeToken&action=add-url&s=myTorrent", "add a torrent to the downloads");
equals(password, "password", "on a password protected host");
equals(username, "user", "with the given user");
});
</script>
</head>
<body>
<h1 id="qunit-header">Chrometorrent tests</h1>
<h2 id="qunit-banner"></h2>
<div id="qunit-testrunner-toolbar"></div>
<h2 id="qunit-userAgent"></h2>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture">test markup, will be hidden</div>
</body>
</html>