-
-
Notifications
You must be signed in to change notification settings - Fork 43
/
Copy pathorca_serve_graph-only_test.js
82 lines (72 loc) · 1.67 KB
/
orca_serve_graph-only_test.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
const tap = require('tap')
const Application = require('spectron').Application
const request = require('request')
const { paths } = require('../common')
const PORT = 9109
const SERVER_URL = `http://localhost:${PORT}`
const app = new Application({
path: paths.bin,
args: ['serve', '--port', PORT, '--graph-only']
})
tap.tearDown(() => {
if (app && app.isRunning()) {
app.stop()
}
})
tap.test('should launch', t => {
app.start().then(() => {
app.client.getWindowCount().then(cnt => {
// Only one window since only graph component should be running
t.equal(cnt, 1)
t.end()
})
})
})
tap.test('should reply pong to ping POST', t => {
request.post(SERVER_URL + '/ping', (err, res, body) => {
if (err) t.fail(err)
t.equal(res.statusCode, 200, 'code')
t.equal(body, 'pong', 'body')
t.end()
})
})
tap.test('should work for *plotly-graph* component', t => {
request({
method: 'POST',
url: SERVER_URL + '/',
body: JSON.stringify({
figure: {
layout: {
data: [{y: [1, 2, 1]}]
}
}
})
}, (err, res, body) => {
if (err) t.fail(err)
t.equal(res.statusCode, 200, 'code')
t.type(body, 'string')
t.end()
})
})
tap.test('should teardown', t => {
app.stop()
.catch(t.fail)
.then(t.end)
})
tap.test('should not work for *plotly-thumbnail* component', t => {
request({
method: 'POST',
url: SERVER_URL + '/thumbnail',
body: JSON.stringify({
figure: {
layout: {
data: [{y: [1, 2, 1]}]
}
}
})
}, (err, res) => {
t.equal(err.code, 'ECONNREFUSED')
t.equal(res, undefined, 'should be undefined')
t.end()
})
})