forked from rchipka/node-osmosis
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.js
92 lines (82 loc) · 2.21 KB
/
run.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
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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
var osmosis = require('../index'),
server = require('./server'),
url = server.host + ':' + server.port;
var name = function () {
return true;
};
module.exports.immediate = function (assert) {
var calledThen = false;
new osmosis(url + '/run')
.then(function (context, data, next, done) {
assert.equal(context.get('div').textContent, 'loaded');
calledThen = true;
next(context, data);
done();
})
.done(function () {
assert.ok(calledThen);
assert.done();
}).run();
};
module.exports.multiple = function (assert) {
var count = 0, r1, r2,
instance =
new osmosis.get(url + '/run')
.then(function () {
count++;
})
.done(function () {
if (count === 2) {
assert.done();
}
});
r1 = instance.run();
r2 = instance.run();
};
module.exports.new_instance_command = function (assert) {
var calledThen = false,
calledCB = false,
instance =
new osmosis.get(url + '/run')
.then(function (context, data, next, done) {
assert.equal(context.get('div').textContent, 'loaded');
calledThen = true;
next(context, data);
done();
})
.done(function () {
assert.ok(calledCB);
assert.ok(calledThen);
assert.done();
});
setTimeout(function () {
calledCB = true;
instance.run();
}, 500);
};
module.exports.new_instance_get = function (assert) {
var calledThen = false,
calledCB = false,
instance =
new osmosis(url + '/run')
.then(function (context, data, next, done) {
assert.equal(context.get('div').textContent, 'loaded');
calledThen = true;
next(context, data);
done();
})
.done(function () {
assert.ok(calledCB);
assert.ok(calledThen);
assert.done();
});
setTimeout(function () {
calledCB = true;
instance.run();
}, 500);
};
server('/run', function (url, req, res) {
res.setHeader("Content-Type", "text/html");
res.write('<div>loaded</div>');
res.end();
});