Skip to content

Commit e6c94c8

Browse files
author
Perki
committed
Add tests codes
1 parent c3668c4 commit e6c94c8

File tree

10 files changed

+117
-104
lines changed

10 files changed

+117
-104
lines changed

components/pryv-monitor/test/monitor.test.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,26 +6,26 @@
66

77
require('./load-helpers');
88

9-
describe('Monitor', function () {
9+
describe('[MONX] Monitor', function () {
1010
this.timeout(20000);
1111

1212
before(async function () {
1313
this.timeout(20000);
1414
await prepareAndCreateBaseStreams();
1515
});
1616

17-
describe('init', () => {
18-
it('can be initialized with an apiEndpoint', async () => {
17+
describe('[MINX] init', () => {
18+
it('[MINA] can be initialized with an apiEndpoint', async () => {
1919
const monitor = new pryv.Monitor(apiEndpoint, { limit: 1 });
2020
await monitor.start();
2121
});
2222

23-
it('can be initialized with a connection', async () => {
23+
it('[MINB] can be initialized with a connection', async () => {
2424
const monitor = new pryv.Monitor(conn, { limit: 1 });
2525
await monitor.start();
2626
});
2727

28-
it('throw Error on invalid apiEndpoint', async () => {
28+
it('[MINC] throw Error on invalid apiEndpoint', async () => {
2929
let passed = true;
3030
try {
3131
pryv.Monitor('BlipBlop', { limit: 1 });
@@ -37,7 +37,7 @@ describe('Monitor', function () {
3737
});
3838
});
3939

40-
describe('notifications', () => {
40+
describe('[MNTX] notifications', () => {
4141
let monitor = null;
4242
beforeEach(async () => {
4343
monitor = new pryv.Monitor(conn, { limit: 1 });
@@ -47,7 +47,7 @@ describe('Monitor', function () {
4747
monitor.stop();
4848
});
4949

50-
it('Load events at start', async function () {
50+
it('[MNTA] Load events at start', async function () {
5151
let count = 0;
5252
monitor.on('event', function (event) {
5353
count++;
@@ -67,7 +67,7 @@ describe('Monitor', function () {
6767
expect(count).to.be.gt(0);
6868
});
6969

70-
it('Detect new events added', async function () {
70+
it('[MNTB] Detect new events added', async function () {
7171
let count = 0;
7272
await monitor.start();
7373

components/pryv-monitor/test/socket.test.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,16 @@
77
require('./load-helpers');
88
require('@pryv/socket.io')(pryv);
99

10-
describe('Monitor + Socket.IO', function () {
10+
describe('[MSKX] Monitor + Socket.IO', function () {
1111
this.timeout(20000);
1212

1313
before(async () => {
1414
await prepareAndCreateBaseStreams();
1515
});
1616

17-
describe('socket updates', function () {
17+
describe('[MSUX] socket updates', function () {
1818
this.timeout(25000);
19-
it('Detect new events added', async function () {
19+
it('[MSUA] Detect new events added', async function () {
2020
const monitor = new pryv.Monitor(apiEndpoint, { limit: 1 })
2121
.addUpdateMethod(new pryv.Monitor.UpdateMethod.Socket());
2222
await monitor.start();
@@ -47,8 +47,8 @@ describe('Monitor + Socket.IO', function () {
4747
});
4848
});
4949

50-
describe('stop', () => {
51-
it('Monitor stops when requested', async function () {
50+
describe('[MSTX] stop', () => {
51+
it('[MSTA] Monitor stops when requested', async function () {
5252
this.timeout(20000);
5353
const monitor = new pryv.Monitor(apiEndpoint, { limit: 1 })
5454
.addUpdateMethod(new pryv.Monitor.UpdateMethod.Socket());

components/pryv-monitor/test/timer.test.js

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66

77
require('./load-helpers');
88

9-
describe('Monitor + EventsTimer', function () {
9+
describe('[TIMX] Monitor + EventsTimer', function () {
1010
this.timeout(20000);
1111

1212
before(async () => {
1313
await prepareAndCreateBaseStreams();
1414
});
1515

16-
describe('init', () => {
17-
it('throw error if timer is not inistialized with correct time', async () => {
16+
describe('[TINX] init', () => {
17+
it('[TINA] throw error if timer is not inistialized with correct time', async () => {
1818
const monitor = new pryv.Monitor(apiEndpoint, { limit: 1 });
1919
try {
2020
/* eslint-disable-next-line no-new */
@@ -26,8 +26,8 @@ describe('Monitor + EventsTimer', function () {
2626
});
2727
});
2828

29-
describe('timer updates', () => {
30-
it('Detect new events added', async function () {
29+
describe('[TUPX] timer updates', () => {
30+
it('[TUPA] Detect new events added', async function () {
3131
const monitor = new pryv.Monitor(apiEndpoint, { limit: 1 })
3232
.addUpdateMethod(new pryv.Monitor.UpdateMethod.EventsTimer(1));
3333
await monitor.start();
@@ -58,8 +58,8 @@ describe('Monitor + EventsTimer', function () {
5858
});
5959
});
6060

61-
describe('stop', () => {
62-
it('Monitor stops when requested', async function () {
61+
describe('[TSTX] stop', () => {
62+
it('[TSTA] Monitor stops when requested', async function () {
6363
this.timeout(20000);
6464
const monitor = await new pryv.Monitor(apiEndpoint, { limit: 1 })
6565
.addUpdateMethod(new pryv.Monitor.UpdateMethod.EventsTimer(1));

components/pryv-socket.io/test/socket.io.test.js

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ require('@pryv/socket.io')(pryv);
1111
let conn = null;
1212
const testStreamId = 'socket-test';
1313

14-
describe('Socket.IO', function () {
14+
describe('[SKIX] Socket.IO', function () {
1515
this.timeout(20000);
1616
let apiEndpoint;
1717
let apiEndpointBogusToken;
@@ -40,8 +40,8 @@ describe('Socket.IO', function () {
4040
expect(res[0].error.id).to.equal('item-already-exists');
4141
});
4242

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 () => {
4545
conn = new pryv.Connection(apiEndpointBogusUsername);
4646
try {
4747
await conn.socket.open();
@@ -58,7 +58,7 @@ describe('Socket.IO', function () {
5858
throw new Error('Should throw an error');
5959
});
6060

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 () => {
6262
conn = new pryv.Connection(apiEndpointBogusToken);
6363
try {
6464
await conn.socket.open();
@@ -69,7 +69,7 @@ describe('Socket.IO', function () {
6969
});
7070
});
7171

72-
describe('init on valid endpoint', () => {
72+
describe('[SIVX] init on valid endpoint', () => {
7373
beforeEach(async () => {
7474
conn = new pryv.Connection(apiEndpoint);
7575
});
@@ -78,7 +78,7 @@ describe('Socket.IO', function () {
7878
conn = null;
7979
});
8080

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 () => {
8282
try {
8383
await conn.socket.api([{ method: 'events.get', params: {} }]);
8484
} catch (e) {
@@ -87,7 +87,7 @@ describe('Socket.IO', function () {
8787
throw new Error('Should throw an error');
8888
});
8989

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 () => {
9191
try {
9292
await conn.socket.on('eventsChanged');
9393
} catch (e) {
@@ -96,13 +96,13 @@ describe('Socket.IO', function () {
9696
throw new Error('Should throw an error');
9797
});
9898

99-
it('Correct initialization should return socket instance', async () => {
99+
it('[SIVC] Correct initialization should return socket instance', async () => {
100100
const socket = await conn.socket.open();
101101
expect(socket._io).to.exist;
102102
});
103103
});
104104

105-
describe('socket.api', () => {
105+
describe('[SAPX] socket.api', () => {
106106
before(async () => {
107107
conn = new pryv.Connection(apiEndpoint);
108108
await conn.socket.open();
@@ -112,7 +112,7 @@ describe('Socket.IO', function () {
112112
conn = null;
113113
});
114114

115-
it('Handle correctly batch calls', async () => {
115+
it('[SAPA] Handle correctly batch calls', async () => {
116116
const res = await conn.socket.api([{ method: 'streams.get', params: {} }]);
117117
expect(res[0]).to.exist;
118118
expect(res[0].streams).to.exist;
@@ -121,7 +121,7 @@ describe('Socket.IO', function () {
121121
// we don't test further .api() as it relies on the implementation of pryv.Connection
122122
});
123123

124-
describe('notification', () => {
124+
describe('[SNTX] notification', () => {
125125
before(async () => {
126126
conn = new pryv.Connection(apiEndpoint);
127127
await conn.socket.open();
@@ -131,7 +131,7 @@ describe('Socket.IO', function () {
131131
conn = null;
132132
});
133133

134-
it('Fails on requesting an invalid notifcation', async () => {
134+
it('[SNTA] Fails on requesting an invalid notifcation', async () => {
135135
try {
136136
conn.socket.on('Bogus', () => {});
137137
} catch (e) {
@@ -140,15 +140,15 @@ describe('Socket.IO', function () {
140140
throw new Error('Should fail');
141141
});
142142

143-
it('Catches eventChanges', (done) => {
143+
it('[SNTB] Catches eventChanges', (done) => {
144144
function onEventChanged () {
145145
return done();
146146
}
147147
conn.socket.on('eventsChanged', onEventChanged);
148148
conn.api([{ method: 'events.create', params: { type: 'note/txt', streamId: testStreamId, content: 'hello' } }]);
149149
});
150150

151-
it('Catches streamChanges', (done) => {
151+
it('[SNTC] Catches streamChanges', (done) => {
152152
function onStreamChange () {
153153
return done();
154154
}
@@ -157,7 +157,7 @@ describe('Socket.IO', function () {
157157
});
158158

159159
/** Keep this test the last on of this sequence */
160-
it('Catches disconnect', (done) => {
160+
it('[SNTD] Catches disconnect', (done) => {
161161
function onDisconnect (reason) {
162162
expect(reason).to.equal('io client disconnect');
163163
return done();

components/pryv/test/Browser.AuthController.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ const utils = require('../src/utils.js');
88
const Service = require('../src/Service');
99
const AuthController = require('../src/Auth/AuthController.js');
1010

11-
describe('Browser.LoginButton', function () {
11+
describe('[AUTX] Browser.LoginButton', function () {
1212
this.timeout(15000);
1313

1414
let auth;
@@ -43,7 +43,7 @@ describe('Browser.LoginButton', function () {
4343
await auth.init();
4444
});
4545

46-
it('getReturnURL()', async function () {
46+
it('[AUTA] getReturnURL()', async function () {
4747
const myUrl = 'https://mysite.com/bobby';
4848
let error = null;
4949
try {
@@ -71,12 +71,12 @@ describe('Browser.LoginButton', function () {
7171
expect(auth.getReturnURL('self?', myUrl, fakeNavigator)).to.equal(myUrl + '?');
7272
});
7373

74-
it('browserIsMobileOrTablet()', async function () {
74+
it('[AUTB] browserIsMobileOrTablet()', async function () {
7575
expect(utils.browserIsMobileOrTablet({ userAgent: 'android' })).to.be.true;
7676
expect(utils.browserIsMobileOrTablet({ userAgent: 'Safari' })).to.be.false;
7777
});
7878

79-
it('cleanURLFromPrYvParams()', async function () {
79+
it('[AUTC] cleanURLFromPrYvParams()', async function () {
8080
expect('https://my.Url.com/?bobby=2').to.equal(utils.cleanURLFromPrYvParams(
8181
'https://my.Url.com/?bobby=2&prYvZoutOu=1&prYvstatus=2jsadh'));
8282

components/pryv/test/Browser.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ function genSettings () {
1717
};
1818
}
1919

20-
describe('Browser', function () {
20+
describe('[BRWX] Browser', function () {
2121
this.timeout(15000);
2222

2323
before(async function () {
@@ -46,7 +46,7 @@ describe('Browser', function () {
4646
delete global.location;
4747
});
4848

49-
it('setupAuth()', async () => {
49+
it('[BRWA] setupAuth()', async () => {
5050
const settings = genSettings();
5151
let AuthLoaded = false;
5252
settings.onStateChange = function (state) {
@@ -70,7 +70,7 @@ describe('Browser', function () {
7070
}
7171
});
7272

73-
it('serviceInfoFromUrl()', async () => {
73+
it('[BRWB] serviceInfoFromUrl()', async () => {
7474
expect('https://zou.zou/service/info').to.equal(pryv.Browser.serviceInfoFromUrl());
7575
});
7676
});

0 commit comments

Comments
 (0)