js-klikvet-logic-worker 2.3.29 → 2.3.31
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/worker.d.mts +32 -15
- package/dist/worker.d.mts.map +1 -1
- package/dist/worker.mjs +218 -127
- package/dist/worker.mjs.map +1 -1
- package/package.json +12 -12
- package/src/worker.mts +217 -128
- package/test/{worker.test.js → worker.test.mjs} +17 -19
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
//@ts-check
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const { Client, Broker } = require('cry-ebus2');
|
|
6
|
-
const { KlikvetLogicWorker } = require('../worker');
|
|
2
|
+
import { expect} from 'chai'
|
|
3
|
+
import { Client, Broker } from 'cry-ebus2'
|
|
4
|
+
import { KlikvetLogicWorker } from '../dist/worker.mjs'
|
|
7
5
|
|
|
8
6
|
// non-blocking version
|
|
9
7
|
function sleep(ms){ return new Promise( resolve => setTimeout( resolve , ms ) ) }
|
|
@@ -29,27 +27,27 @@ let client = new Client( )
|
|
|
29
27
|
|
|
30
28
|
describe("worker", async function () {
|
|
31
29
|
|
|
32
|
-
this.timeout(
|
|
30
|
+
this.timeout(30000)
|
|
33
31
|
|
|
34
32
|
//#region WORKER
|
|
35
33
|
|
|
36
34
|
it('should have a broker', async function () {
|
|
37
|
-
broker.
|
|
35
|
+
expect(broker).to.not.equal(null)
|
|
38
36
|
});
|
|
39
37
|
it('should have a client', async function () {
|
|
40
|
-
client.
|
|
38
|
+
expect(client).to.not.equal(null)
|
|
41
39
|
});
|
|
42
40
|
it('worker should respond to a simple ping', async function () {
|
|
43
|
-
let res =
|
|
44
|
-
res.
|
|
41
|
+
let res = await client.request('klikvet', 'ping')
|
|
42
|
+
expect(!!res.match(/pong/)).to.be.true;
|
|
45
43
|
});
|
|
46
44
|
it('worker should respond to a ping', async function () {
|
|
47
45
|
let res = await client.request('klikvet',{ operation: 'ping' })
|
|
48
|
-
res.ping.
|
|
46
|
+
expect(res.ping).to.equal('pong')
|
|
49
47
|
});
|
|
50
48
|
it('worker should return help', async function () {
|
|
51
49
|
let res = await client.request('klikvet',{ operation: 'help' })
|
|
52
|
-
//res.log.
|
|
50
|
+
// expect(res.log).to.be.a('string')
|
|
53
51
|
});
|
|
54
52
|
|
|
55
53
|
//#endregion
|
|
@@ -58,8 +56,8 @@ describe("worker", async function () {
|
|
|
58
56
|
|
|
59
57
|
it('promet should return config', async function () {
|
|
60
58
|
let res = await client.request('klikvet',{ operation: 'promet-get-config'});
|
|
61
|
-
res.possibleGroupings.
|
|
62
|
-
res.possibleResults.
|
|
59
|
+
expect(res.possibleGroupings).to.be.a("object")
|
|
60
|
+
expect(res.possibleResults).to.be.a("object")
|
|
63
61
|
});
|
|
64
62
|
|
|
65
63
|
it('promet shold create pipeline', async function () {
|
|
@@ -70,7 +68,7 @@ describe("worker", async function () {
|
|
|
70
68
|
groupBy: "kategorija artikla"
|
|
71
69
|
}
|
|
72
70
|
});
|
|
73
|
-
res.pipeline.
|
|
71
|
+
expect(res.pipeline).to.be.an("array")
|
|
74
72
|
});
|
|
75
73
|
|
|
76
74
|
it('promet should exec pipeline from pipeline', async function () {
|
|
@@ -82,7 +80,7 @@ describe("worker", async function () {
|
|
|
82
80
|
}
|
|
83
81
|
});
|
|
84
82
|
|
|
85
|
-
res.pipeline.
|
|
83
|
+
expect(res.pipeline).to.be.an("array")
|
|
86
84
|
|
|
87
85
|
|
|
88
86
|
let res2 = await client.request('klikvet',{
|
|
@@ -115,7 +113,7 @@ describe("worker", async function () {
|
|
|
115
113
|
timeQuery: "januar 2020",
|
|
116
114
|
}
|
|
117
115
|
});
|
|
118
|
-
res.pipeline.
|
|
116
|
+
expect(res.pipeline).to.be.an("array")
|
|
119
117
|
});
|
|
120
118
|
|
|
121
119
|
it('racuni.isci should exec pipeline from pipeline', async function () {
|
|
@@ -126,7 +124,7 @@ describe("worker", async function () {
|
|
|
126
124
|
}
|
|
127
125
|
});
|
|
128
126
|
|
|
129
|
-
res.pipeline.
|
|
127
|
+
expect(res.pipeline).to.be.an("array")
|
|
130
128
|
|
|
131
129
|
let res2 = await client.request('klikvet',{
|
|
132
130
|
operation: 'racuni-isci-exec-pipeline',
|
|
@@ -177,4 +175,4 @@ describe("worker", async function () {
|
|
|
177
175
|
worker.stop();
|
|
178
176
|
process.exit(0)
|
|
179
177
|
},3000)
|
|
180
|
-
});
|
|
178
|
+
});
|