/* eslint-disable @typescript-eslint/no-unused-expressions,@typescript-eslint/require-await */
import 'mocha'
-import * as io from 'socket.io-client'
+import { io } from 'socket.io-client'
import {
cleanupTests,
})
describe('When connecting to my notification socket', function () {
+
it('Should fail with no token', function (next) {
const socket = io(`http://localhost:${server.port}/user-notifications`, { reconnection: false })
- socket.on('error', function () {
- socket.removeListener('error', this)
+ socket.once('connect_error', function () {
socket.disconnect()
next()
})
reconnection: false
})
- socket.on('error', function () {
- socket.removeListener('error', this)
+ socket.once('connect_error', function () {
socket.disconnect()
next()
})
next(new Error('Error in connection: ' + err))
}
- socket.on('error', errorListener)
+ socket.on('connect_error', errorListener)
- socket.on('connect', async () => {
- socket.removeListener('error', errorListener)
+ socket.once('connect', async () => {
socket.disconnect()
await wait(500)