diff --git a/.travis.yml b/.travis.yml index 681a3b5e..e96195f9 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: node_js node_js: - 14 - 12 - - 10 cache: npm: false diff --git a/server/distribute/export.spec.js b/server/distribute/export.spec.js index c828415a..181f22c7 100644 --- a/server/distribute/export.spec.js +++ b/server/distribute/export.spec.js @@ -1,5 +1,7 @@ 'use strict'; +const {once} = require('events'); + const test = require('supertape'); const io = require('socket.io-client'); @@ -23,22 +25,20 @@ test('distribute: export', async (t) => { const url = `http://localhost:${port}/distribute?port=${1111}`; const socket = io.connect(url); - socket.on('connect', () => { - socket.emit('auth', 'a'); - }); + await once(socket, 'connect'); + socket.emit('auth', 'a'); - socket.on('accept', () => { - config('vim', false); - config('auth', true); - }); + await once(socket, 'accept'); + config('vim', false); + config('auth', true); - socket.on('change', async () => { - socket.close(); - await done(); - - t.pass('should emit change'); - t.end(); - }); + await once(socket, 'change'); + + socket.close(); + await done(); + + t.pass('should emit change'); + t.end(); }); test('distribute: export: config', async (t) => { @@ -56,16 +56,16 @@ test('distribute: export: config', async (t) => { const url = `http://localhost:${port}/distribute?port=${1111}`; const socket = io.connect(url); - socket.on('connect', () => { + socket.once('connect', () => { socket.emit('auth', 'a'); }); - socket.on('config', async (data) => { - socket.close(); - await done(); - - t.equal(typeof data, 'object', 'should emit object'); - t.end(); - }); + const data = await once(socket, 'config'); + + socket.close(); + await done(); + + t.equal(typeof data, 'object', 'should emit object'); + t.end(); }); diff --git a/test/server/console.js b/test/server/console.js index 909b9da6..104a7ff1 100644 --- a/test/server/console.js +++ b/test/server/console.js @@ -1,6 +1,7 @@ 'use strict'; const path = require('path'); +const {once} = require('events'); const test = require('supertape'); const io = require('socket.io-client'); @@ -18,13 +19,14 @@ test('cloudcmd: console: enabled', async (t) => { const socket = io(`http://localhost:${port}/console`); socket.emit('auth', configFn('username'), configFn('password')); - socket.once('data', (data) => { - done(); - socket.close(); - - t.equal(data, 'client #1 console connected\n', 'should emit data event'); - t.end(); - }); + + const [data] = await once(socket, 'data'); + + socket.close(); + await done(); + + t.equal(data, 'client #1 console connected\n', 'should emit data event'); + t.end(); }); test('cloudcmd: console: disabled', async (t) => { @@ -35,12 +37,12 @@ test('cloudcmd: console: disabled', async (t) => { const {port, done} = await connect({config}); const socket = io(`http://localhost:${port}/console`); - socket.on('error', (error) => { - socket.close(); - done(); - - t.equal(error, 'Invalid namespace', 'should emit error'); - t.end(); - }); + const [error] = await once(socket, 'error'); + + socket.close(); + await done(); + + t.equal(error, 'Invalid namespace', 'should emit error'); + t.end(); });