-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain-tests.js
83 lines (64 loc) · 1.91 KB
/
main-tests.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
const { throws, rejects, deepEqual } = require('assert');
const mod = require('./main.js');
describe('OLSKQueueAPI', function test_OLSKQueueAPI() {
const _OLSKQueueAPI = function (inputData) {
return Object.assign(Object.assign({}, mod), {
_DataFoilQueue: (function () {}),
}, inputData).OLSKQueueAPI(inputData.params);
};
it('returns object', function() {
deepEqual(typeof mod.OLSKQueueAPI(), 'object');
});
context('_OLSKQueueObject', function () {
it('calls _DataFoilQueue', function () {
deepEqual(_OLSKQueueAPI({
_DataFoilQueue: (function () {
return [...arguments];
}),
})._OLSKQueueObject, [mod._DataQueueConfig()]);
});
it('throws if not object', function () {
throws(function () {
mod.OLSKQueueAPI(null);
}, /OLSKErrorInputNotValid/);
});
it('passes inputData', function () {
const item = {
[Math.random().toString()]: Math.random().toString(),
};
deepEqual(_OLSKQueueAPI({
_DataFoilQueue: (function () {
return [...arguments];
}),
params: Object.assign({}, item),
})._OLSKQueueObject, [Object.assign(mod._DataQueueConfig(), item)]);
});
});
context('OLSKQueueAdd', function () {
it('throws if not function', function () {
throws(function () {
mod.OLSKQueueAPI().OLSKQueueAdd(null);
}, /OLSKErrorInputNotValid/);
});
it('resolves outputData', async function () {
const item = Math.random().toString();
deepEqual(await mod.OLSKQueueAPI().OLSKQueueAdd(function () {
return item;
}), item);
});
it('rejects if not object', async function () {
const item = Math.random().toString();
await rejects(mod.OLSKQueueAPI().OLSKQueueAdd(function () {
throw new Error(item);
}), new RegExp(item));
});
});
});
describe('_DataQueueConfig', function test__DataQueueConfig() {
it('returns object', function() {
deepEqual(mod._DataQueueConfig(), {
concurrency: 1,
autostart: true,
});
});
});