Skip to content

Commit 85287f7

Browse files
committed
update
1 parent 46bd56f commit 85287f7

1 file changed

Lines changed: 8 additions & 8 deletions

File tree

src/communication/WebSocketConnection.test.ts

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ const encodeServerMessage = (strData: string) => {
1212
};
1313

1414
describe('Test Connection module', function() {
15-
let mockServer: Server;
15+
let mockServer: Server | undefined;
1616

1717
beforeEach(function() {
1818
// tslint:disable-next-line:no-any
@@ -21,12 +21,12 @@ describe('Test Connection module', function() {
2121
(<any>window).isTestEnvironnement = true;
2222
});
2323

24-
afterEach(() => {
24+
afterEach((done) => {
2525
if (mockServer) {
26-
mockServer.stop(() => {
27-
/**/
28-
});
26+
mockServer.close(); // Utiliser close() et non stop()
27+
mockServer = undefined;
2928
}
29+
done(); // Pour Jest : signaler la fin du teardown
3030
});
3131

3232
describe('Test createSession method', function() {
@@ -41,7 +41,7 @@ describe('Test Connection module', function() {
4141
})
4242
.then(session => {
4343
expect(session).not.toBe(null);
44-
mockServer.stop(done);
44+
mockServer?.stop(done);
4545
})
4646
.catch(err => {
4747
console.log(err);
@@ -72,7 +72,7 @@ describe('Test Connection module', function() {
7272
connection.createSession(xcApiFileName).catch(error => {
7373
// it refers explicitly to the unknown Api on the error message, not to some random crash
7474
expect(error.message).toMatch(xcApiFileName);
75-
mockServer.stop(done);
75+
mockServer?.stop(done);
7676
});
7777
});
7878

@@ -90,7 +90,7 @@ describe('Test Connection module', function() {
9090
mockServer = new Server(serverUrl);
9191
const xcApiFileName = 'api.xcApi';
9292
mockServer.on('connection', server => {
93-
mockServer.close(undefined);
93+
mockServer?.close(undefined);
9494
});
9595
new XComponent()
9696
.connect(serverUrl, new FakeErrorHandler(err => done()))

0 commit comments

Comments
 (0)