-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
111 lines (88 loc) · 3.08 KB
/
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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
var dotest = require ('dotest');
var app = require ('./');
var config = {
protocol: process.env.MFC_PROTOCOL || 'http',
hostname: process.env.MFC_HOSTNAME || null,
port: process.env.MFC_PORT || 80,
prefix: process.env.MFC_PREFIX || '',
ippPort: process.env.MFC_IPPPORT || 631,
timeout: process.env.MFC_TIMEOUT || 5000
};
var cacheSleep = null;
var mfc = app (config);
dotest.add ('Module', function (test) {
var general = mfc && mfc.general;
test ()
.isFunction ('fail', 'exports', app)
.isObject ('fail', 'interface', mfc)
.isFunction ('fail', '.current', mfc && mfc.current)
.isFunction ('fail', '.sleep', mfc && mfc.sleep)
.isObject ('fail', '.general', general)
.isFunction ('fail', '.general.status', general && general.status)
.isFunction ('fail', '.general.information', general && general.information)
.done ();
});
dotest.add ('Method .sleep - get value', function (test) {
mfc.sleep (function (err, data) {
var value = data && data.value;
if (value && value.key) {
cacheSleep = value.key;
}
test (err)
.isObject ('fail', 'data', data)
.isObject ('fail', 'data.presets', data && data.presets)
.isObject ('fail', 'data.value', value)
.isNumber ('fail', 'data.value.key', value && value.key)
.isNumber ('fail', 'data.presets[1]', data && data.presets && data.presets[1])
.done ();
});
});
dotest.add ('Method .sleep - set value', function (test) {
mfc.sleep (cacheSleep, function (err, data) {
test (err)
.isExactly ('fail', 'data', data, true)
.done ();
});
});
dotest.add ('Method .current', function (test) {
mfc.current (function (err, data) {
test (err)
.isObject ('fail', 'data', data)
.isString ('fail', 'data.state', data && data.state)
.isString ('fail', 'data.stateReasons', data && data.stateReasons)
.isNumber ('fail', 'data.jobs', data && data.jobs)
.isNumber ('fail', 'data.uptime', data && data.uptime)
.isDate ('fail', 'data.uptimeDate', data && data.uptimeDate)
.isObject ('fail', 'data.ink', data && data.ink)
.info (data && data.ink)
.done ();
});
});
dotest.add ('Method general.status', function (test) {
mfc.general.status (function (err, data) {
var i;
test (err)
.isObject ('fail', 'data', data)
.isString ('fail', 'data.model', data && data.model)
.isString ('fail', 'data.status', data && data.status)
.isString ('fail', 'data.message', data && data.message)
.isObject ('fail', 'data.ink', data && data.ink)
.isNotEmpty ('fail', 'data.ink', data && data.ink);
for (i in data && data.ink) {
test ()
.isNumber ('fail', 'data.ink.' + i, data.ink [i]);
}
test ()
.done ();
});
});
dotest.add ('Method general.information', function (test) {
mfc.general.information (function (err, data) {
test (err)
.isObject ('fail', 'data', data)
.isString ('fail', 'data.ip_address', data && data.ip_address)
.isNumber ('fail', 'data.page_counter', data && data.page_counter)
.done ();
});
});
dotest.run ();