diff --git a/app.js b/app.js index c68de67..da62cb7 100644 --- a/app.js +++ b/app.js @@ -31,7 +31,7 @@ io.on('connection', (socket) => { name = (name || "").trim() //if name is empty(null), do nothing - if(!name) return socket.emit('user invalid', {username: `${name} is invalid.`}); + if(!name) return socket.emit('user invalid', `This user name is invalid.`); //if username is not taken else if(rooms[0].users.indexOf(name) == -1) { diff --git a/package.json b/package.json index 74e26e7..167d51a 100644 --- a/package.json +++ b/package.json @@ -5,12 +5,12 @@ "main": "index.js", "scripts": { "start": "node app.js", - "test:watch": "mocha --watch ./*.test.js", - "test": "mocha ./*.test.js" + "test:watch": "mocha --watch ./tests/**/*.test.js", + "test": "mocha ./tests/**/*.test.js" }, "engines": { "npm": "3.10.10", - "node": "12.19.0" + "node": "6.9.4" }, "repository": { "type": "git", @@ -27,8 +27,8 @@ "socket.io": "^1.7.2" }, "devDependencies": { - "chai": "^4.2.0", - "mocha": "^8.2.0", - "socket.io-client": "^2.3.1" + "chai": "4.2.0", + "mocha": "6.2.3", + "socket.io-client": "2.3.1" } } diff --git a/app.test.js b/tests/app.test.js similarity index 94% rename from app.test.js rename to tests/app.test.js index bcb0b77..16d5eee 100644 --- a/app.test.js +++ b/tests/app.test.js @@ -34,9 +34,8 @@ describe("App.js", () => { assert.isTrue(client.connected); client.on("user invalid", (data) => { - assert.isObject(data); - assert.hasAllKeys(data, "username"); - assert.strictEqual(data.username, " is invalid."); + assert.isString(data); + assert.strictEqual(data, "This user name is invalid."); done(); });