@schukai/monster 3.2.0 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- package/README.md +1 -1
- package/package.json +1 -1
- package/source/data/datasource/{restapi.mjs → server/restapi.mjs} +63 -88
- package/source/data/datasource/server/webconnect.mjs +201 -0
- package/source/data/datasource/server.mjs +108 -0
- package/source/i18n/locale.mjs +1 -1
- package/source/monster.mjs +11 -3
- package/source/net/webconnect/message.mjs +55 -0
- package/source/{data/datasource/websocket.mjs → net/webconnect.mjs} +109 -148
- package/source/types/global.mjs +2 -2
- package/source/types/mediatype.mjs +1 -1
- package/source/types/observablequeue.mjs +110 -0
- package/source/types/proxyobserver.mjs +2 -2
- package/source/types/uniquequeue.mjs +9 -6
- package/source/types/version.mjs +1 -1
- package/test/cases/data/datasource/{restapi.mjs → server/restapi.mjs} +19 -13
- package/test/cases/data/datasource/server/websocket.mjs +194 -0
- package/test/cases/data/datasource/server.mjs +53 -0
- package/test/cases/monster.mjs +1 -1
- package/test/cases/net/webconnect/message.mjs +50 -0
- package/test/cases/net/webconnect.mjs +116 -0
- package/test/cases/types/observablequeue.mjs +17 -0
- package/test/cases/types/queue.mjs +4 -1
- package/test/web/import.js +6 -2
- package/test/web/test.html +3 -3
- package/test/web/tests.js +891 -393
- package/test/cases/data/datasource/websocket.mjs +0 -107
@@ -1,107 +0,0 @@
|
|
1
|
-
import {expect} from "chai"
|
2
|
-
import {WebSocketDatasource} from "../../../../../application/source/data/datasource/websocket.mjs";
|
3
|
-
import {initWebSocket} from "../../../util/websocket.mjs";
|
4
|
-
|
5
|
-
const testUrl = "wss://ws.postman-echo.com/raw"
|
6
|
-
|
7
|
-
// const g = getGlobal();
|
8
|
-
// g['WebSocket'] = WS;
|
9
|
-
|
10
|
-
|
11
|
-
describe('Websocket', function () {
|
12
|
-
|
13
|
-
let ds = undefined
|
14
|
-
|
15
|
-
before(function (done) {
|
16
|
-
initWebSocket().then(() => {
|
17
|
-
done()
|
18
|
-
}).catch((e) => {
|
19
|
-
done(e)
|
20
|
-
})
|
21
|
-
});
|
22
|
-
|
23
|
-
afterEach(function (done) {
|
24
|
-
if (ds) {
|
25
|
-
ds.close()
|
26
|
-
}
|
27
|
-
|
28
|
-
// without this, the node test will hang
|
29
|
-
for (const sym of Object.getOwnPropertySymbols(ds)) {
|
30
|
-
if (sym.toString() ==='Symbol(connection)') {
|
31
|
-
if(ds[sym]?.socket?.['terminate']) {
|
32
|
-
ds[sym]?.socket?.['terminate']()
|
33
|
-
}
|
34
|
-
}
|
35
|
-
}
|
36
|
-
|
37
|
-
done()
|
38
|
-
});
|
39
|
-
|
40
|
-
it('should get clone', function () {
|
41
|
-
|
42
|
-
ds = new WebSocketDatasource(testUrl)
|
43
|
-
const clone = ds.getClone()
|
44
|
-
|
45
|
-
expect(clone).to.be.an.instanceof(WebSocketDatasource)
|
46
|
-
|
47
|
-
|
48
|
-
})
|
49
|
-
|
50
|
-
it('should connect', function (done) {
|
51
|
-
ds = new WebSocketDatasource({
|
52
|
-
url: testUrl,
|
53
|
-
reconnect: {
|
54
|
-
enabled: false
|
55
|
-
}
|
56
|
-
});
|
57
|
-
ds.connect()
|
58
|
-
setTimeout(() => {
|
59
|
-
expect(ds.isConnected()).to.be.true;
|
60
|
-
done();
|
61
|
-
}, 500);
|
62
|
-
|
63
|
-
|
64
|
-
})
|
65
|
-
|
66
|
-
it('should send message', function (done) {
|
67
|
-
ds = new WebSocketDatasource({
|
68
|
-
url: testUrl,
|
69
|
-
reconnect: {
|
70
|
-
enabled: false
|
71
|
-
}
|
72
|
-
});
|
73
|
-
ds.connect()
|
74
|
-
|
75
|
-
ds.set({
|
76
|
-
data: {
|
77
|
-
message: "Hello World"
|
78
|
-
}
|
79
|
-
})
|
80
|
-
|
81
|
-
setTimeout(() => {
|
82
|
-
|
83
|
-
ds.write().then(() => {
|
84
|
-
|
85
|
-
ds.set({})
|
86
|
-
expect(ds.get()).to.be.deep.equal({});
|
87
|
-
|
88
|
-
|
89
|
-
setTimeout(() => {
|
90
|
-
|
91
|
-
expect(ds.get()).to.be.deep.equal({
|
92
|
-
data: {
|
93
|
-
message: "Hello World"
|
94
|
-
}
|
95
|
-
});
|
96
|
-
done();
|
97
|
-
}, 1000);
|
98
|
-
}).catch((err) => {
|
99
|
-
done(new Error(err));
|
100
|
-
})
|
101
|
-
},
|
102
|
-
500)
|
103
|
-
|
104
|
-
|
105
|
-
}).timeout(10000);
|
106
|
-
|
107
|
-
});
|