/* 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,
const correctFields: UserNotificationSetting = {
newVideoFromSubscription: UserNotificationSettingValue.WEB,
newCommentOnMyVideo: UserNotificationSettingValue.WEB,
- videoAbuseAsModerator: UserNotificationSettingValue.WEB,
+ abuseAsModerator: UserNotificationSettingValue.WEB,
videoAutoBlacklistAsModerator: UserNotificationSettingValue.WEB,
blacklistOnMyVideo: UserNotificationSettingValue.WEB,
myVideoImportFinished: UserNotificationSettingValue.WEB,
newFollow: UserNotificationSettingValue.WEB,
newUserRegistration: UserNotificationSettingValue.WEB,
newInstanceFollower: UserNotificationSettingValue.WEB,
- autoInstanceFollowing: UserNotificationSettingValue.WEB
+ autoInstanceFollowing: UserNotificationSettingValue.WEB,
+ abuseNewMessage: UserNotificationSettingValue.WEB,
+ abuseStateChange: UserNotificationSettingValue.WEB
}
it('Should fail with missing fields', async function () {
})
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', () => {
- socket.removeListener('error', this)
+ socket.once('connect_error', function () {
socket.disconnect()
next()
})
reconnection: false
})
- socket.on('error', () => {
- socket.removeListener('error', this)
+ socket.once('connect_error', function () {
socket.disconnect()
next()
})
reconnection: false
})
- const errorListener = socket.on('error', err => {
+ function errorListener (err) {
next(new Error('Error in connection: ' + err))
- })
+ }
+
+ socket.on('connect_error', errorListener)
- socket.on('connect', async () => {
- socket.removeListener('error', errorListener)
+ socket.once('connect', async () => {
socket.disconnect()
await wait(500)