-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.html
52 lines (47 loc) · 1.36 KB
/
test.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
<!DOCTYPE HTML>
<html>
<head>
<script type="text/javascript" src="./core.js"></script>
</head>
<body>
<script type="text/javascript">
console.log('Running Tests')
function testRequestChain (done) {
requestChain([
{ url: "https://raw.githubusercontent.com/monstercat/docs/master/README.md" },
{ url: "https://raw.githubusercontent.com/monstercat/docs/master/bounties.md" }
], (err, results)=> {
if (err)
return done(err)
done()
})
}
function testRequestChainFail (done) {
requestChain([
{ url: "https://raw.githubusercontent.com/monstercat/docs/master/README.md" },
{ url: "https://raw.githubusercontent.com/monstercat/docs/master/404.md" }
], (err, results)=> {
if (err)
return done()
done(Error("It should have errored out."))
})
}
function testRequestDelay (done) {
var spec = 1000
var time = (new Date).getTime()
request({
url: "https://raw.githubusercontent.com/monstercat/docs/master/404.md",
delay: spec
}, (err, body, xhr)=> {
var delta = (new Date()).getTime() - time
if (delta >= spec)
return done()
return done(Error('Delay did not last specification.'))
})
}
testRequestChain((err)=> console.log("testRequestChain: ", err || "succeeded"))
testRequestChainFail((err)=> console.log("testRequestChainFail: ", err || "succeeded"))
testRequestDelay((err)=> console.log("testRequestDelay: ", err || "succeeded"))
</script>
</body>
</html>