@pryv/socket.io 3.0.0 → 3.0.1
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/package.json +1 -1
- package/test/socket.io.test.js +15 -15
package/package.json
CHANGED
package/test/socket.io.test.js
CHANGED
|
@@ -11,7 +11,7 @@ require('@pryv/socket.io')(pryv);
|
|
|
11
11
|
let conn = null;
|
|
12
12
|
const testStreamId = 'socket-test';
|
|
13
13
|
|
|
14
|
-
describe('Socket.IO', function () {
|
|
14
|
+
describe('[SKIX] Socket.IO', function () {
|
|
15
15
|
this.timeout(20000);
|
|
16
16
|
let apiEndpoint;
|
|
17
17
|
let apiEndpointBogusToken;
|
|
@@ -40,8 +40,8 @@ describe('Socket.IO', function () {
|
|
|
40
40
|
expect(res[0].error.id).to.equal('item-already-exists');
|
|
41
41
|
});
|
|
42
42
|
|
|
43
|
-
describe('init on invalid endpoint', () => {
|
|
44
|
-
it('Should throw an error "Not Found" or ENOTFOUND when user is not known', async () => {
|
|
43
|
+
describe('[SIEX] init on invalid endpoint', () => {
|
|
44
|
+
it('[SIEA] Should throw an error "Not Found" or ENOTFOUND when user is not known', async () => {
|
|
45
45
|
conn = new pryv.Connection(apiEndpointBogusUsername);
|
|
46
46
|
try {
|
|
47
47
|
await conn.socket.open();
|
|
@@ -58,7 +58,7 @@ describe('Socket.IO', function () {
|
|
|
58
58
|
throw new Error('Should throw an error');
|
|
59
59
|
});
|
|
60
60
|
|
|
61
|
-
it('Should throw an error "Unauthorized" when token is invalid', async () => {
|
|
61
|
+
it('[SIEB] Should throw an error "Unauthorized" when token is invalid', async () => {
|
|
62
62
|
conn = new pryv.Connection(apiEndpointBogusToken);
|
|
63
63
|
try {
|
|
64
64
|
await conn.socket.open();
|
|
@@ -69,7 +69,7 @@ describe('Socket.IO', function () {
|
|
|
69
69
|
});
|
|
70
70
|
});
|
|
71
71
|
|
|
72
|
-
describe('init on valid endpoint', () => {
|
|
72
|
+
describe('[SIVX] init on valid endpoint', () => {
|
|
73
73
|
beforeEach(async () => {
|
|
74
74
|
conn = new pryv.Connection(apiEndpoint);
|
|
75
75
|
});
|
|
@@ -78,7 +78,7 @@ describe('Socket.IO', function () {
|
|
|
78
78
|
conn = null;
|
|
79
79
|
});
|
|
80
80
|
|
|
81
|
-
it('Should throw an error if conn.socket.api() is called before being open()', async () => {
|
|
81
|
+
it('[SIVA] Should throw an error if conn.socket.api() is called before being open()', async () => {
|
|
82
82
|
try {
|
|
83
83
|
await conn.socket.api([{ method: 'events.get', params: {} }]);
|
|
84
84
|
} catch (e) {
|
|
@@ -87,7 +87,7 @@ describe('Socket.IO', function () {
|
|
|
87
87
|
throw new Error('Should throw an error');
|
|
88
88
|
});
|
|
89
89
|
|
|
90
|
-
it('Should throw an error if conn.socket.on() is called before being open()', async () => {
|
|
90
|
+
it('[SIVB] Should throw an error if conn.socket.on() is called before being open()', async () => {
|
|
91
91
|
try {
|
|
92
92
|
await conn.socket.on('eventsChanged');
|
|
93
93
|
} catch (e) {
|
|
@@ -96,13 +96,13 @@ describe('Socket.IO', function () {
|
|
|
96
96
|
throw new Error('Should throw an error');
|
|
97
97
|
});
|
|
98
98
|
|
|
99
|
-
it('Correct initialization should return socket instance', async () => {
|
|
99
|
+
it('[SIVC] Correct initialization should return socket instance', async () => {
|
|
100
100
|
const socket = await conn.socket.open();
|
|
101
101
|
expect(socket._io).to.exist;
|
|
102
102
|
});
|
|
103
103
|
});
|
|
104
104
|
|
|
105
|
-
describe('socket.api', () => {
|
|
105
|
+
describe('[SAPX] socket.api', () => {
|
|
106
106
|
before(async () => {
|
|
107
107
|
conn = new pryv.Connection(apiEndpoint);
|
|
108
108
|
await conn.socket.open();
|
|
@@ -112,7 +112,7 @@ describe('Socket.IO', function () {
|
|
|
112
112
|
conn = null;
|
|
113
113
|
});
|
|
114
114
|
|
|
115
|
-
it('Handle correctly batch calls', async () => {
|
|
115
|
+
it('[SAPA] Handle correctly batch calls', async () => {
|
|
116
116
|
const res = await conn.socket.api([{ method: 'streams.get', params: {} }]);
|
|
117
117
|
expect(res[0]).to.exist;
|
|
118
118
|
expect(res[0].streams).to.exist;
|
|
@@ -121,7 +121,7 @@ describe('Socket.IO', function () {
|
|
|
121
121
|
// we don't test further .api() as it relies on the implementation of pryv.Connection
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
describe('notification', () => {
|
|
124
|
+
describe('[SNTX] notification', () => {
|
|
125
125
|
before(async () => {
|
|
126
126
|
conn = new pryv.Connection(apiEndpoint);
|
|
127
127
|
await conn.socket.open();
|
|
@@ -131,7 +131,7 @@ describe('Socket.IO', function () {
|
|
|
131
131
|
conn = null;
|
|
132
132
|
});
|
|
133
133
|
|
|
134
|
-
it('Fails on requesting an invalid notifcation', async () => {
|
|
134
|
+
it('[SNTA] Fails on requesting an invalid notifcation', async () => {
|
|
135
135
|
try {
|
|
136
136
|
conn.socket.on('Bogus', () => {});
|
|
137
137
|
} catch (e) {
|
|
@@ -140,7 +140,7 @@ describe('Socket.IO', function () {
|
|
|
140
140
|
throw new Error('Should fail');
|
|
141
141
|
});
|
|
142
142
|
|
|
143
|
-
it('Catches eventChanges', (done) => {
|
|
143
|
+
it('[SNTB] Catches eventChanges', (done) => {
|
|
144
144
|
function onEventChanged () {
|
|
145
145
|
return done();
|
|
146
146
|
}
|
|
@@ -148,7 +148,7 @@ describe('Socket.IO', function () {
|
|
|
148
148
|
conn.api([{ method: 'events.create', params: { type: 'note/txt', streamId: testStreamId, content: 'hello' } }]);
|
|
149
149
|
});
|
|
150
150
|
|
|
151
|
-
it('Catches streamChanges', (done) => {
|
|
151
|
+
it('[SNTC] Catches streamChanges', (done) => {
|
|
152
152
|
function onStreamChange () {
|
|
153
153
|
return done();
|
|
154
154
|
}
|
|
@@ -157,7 +157,7 @@ describe('Socket.IO', function () {
|
|
|
157
157
|
});
|
|
158
158
|
|
|
159
159
|
/** Keep this test the last on of this sequence */
|
|
160
|
-
it('Catches disconnect', (done) => {
|
|
160
|
+
it('[SNTD] Catches disconnect', (done) => {
|
|
161
161
|
function onDisconnect (reason) {
|
|
162
162
|
expect(reason).to.equal('io client disconnect');
|
|
163
163
|
return done();
|