forked from rchipka/node-osmosis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
stop.js
33 lines (30 loc) · 820 Bytes
/
stop.js
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
var osmosis = require('../index'),
server = require('./server'),
url = server.host + ':' + server.port;
module.exports.stop = function (assert) {
var error = false, count = 0, instance =
osmosis.get(url + '/delay-response')
.follow('a')
.follow('a')
.follow('a')
.log(function (msg) {
if (msg.indexOf('loaded') > -1) {
if (++count === 2) {
instance.stop();
}
}
})
.then(function () {
error = true;
})
.done(function () {
assert.equal(count, 2);
assert.equal(error, false);
assert.ok(true);
assert.done();
});
};
server('/delay-response', function (url, req, res) {
res.setHeader("Content-Type", "text/html");
res.end('<a href="/delay-response"></a>');
});