From 3a952a2533902720e9890a7d9ec0b920e78ae231 Mon Sep 17 00:00:00 2001 From: Mario Reder Date: Tue, 3 Jul 2018 06:40:43 +0200 Subject: [PATCH 1/3] chore: Travis CI --- .travis.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .travis.yml diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..ca406b5 --- /dev/null +++ b/.travis.yml @@ -0,0 +1,15 @@ +language: node_js +node_js: + - "8.9.4" +env: + - CXX=g++-4.8 +addons: + apt: + sources: + - ubuntu-toolchain-r-test + packages: + - g++-4.8 +before_install: + - npm install -g yarn --cache-min 999999999 +install: + - yarn \ No newline at end of file From a2848da33a5dcfdb5bf2b24e28600fcaaa109cfb Mon Sep 17 00:00:00 2001 From: Mario Reder Date: Tue, 3 Jul 2018 07:22:31 +0200 Subject: [PATCH 2/3] fix: Client tests - reset all identities per test --- src/Client.spec.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/Client.spec.ts b/src/Client.spec.ts index 4537f7c..b35b060 100644 --- a/src/Client.spec.ts +++ b/src/Client.spec.ts @@ -5,7 +5,7 @@ import { Client, CONNECTION_TIMEOUT, DECOMPRESSION_ERROR, AFK_TIMEOUT, AFK_TIMEO import { IClientServerMessage, Compression, ClientServer, ClientServerMessage, Chat } from './proto/ClientServerMessage' import { IServerClientMessage, ServerClient, ServerClientMessage, ServerMessage, Error as ErrorProto } from './proto/ServerClientMessage' import { - MESSAGES_PER_HALF_MINUTE_THRESHOLD, MESSAGES_PER_HALF_MINUTE_DOS_THRESHOLD, MESSAGE_CHARACTERS_PER_HALF_MINUTE_THRESHOLD, SPAM_NOTIFICATION_MESSAGE, warningLevelMuteMapping + MESSAGES_PER_HALF_MINUTE_THRESHOLD, MESSAGES_PER_HALF_MINUTE_DOS_THRESHOLD, MESSAGE_CHARACTERS_PER_HALF_MINUTE_THRESHOLD, SPAM_NOTIFICATION_MESSAGE, warningLevelMuteMapping, Identity } from './Identity' const addClient = (client: Client) => { @@ -35,7 +35,10 @@ describe('Client', () => { fnMocks[type] = callback }, send: jest.fn(), - close: jest.fn() + close: jest.fn(), + _socket: { + remoteAddress: '127.0.0.1' + } } client = new Client(1, wsMock) addClient(client) @@ -45,6 +48,10 @@ describe('Client', () => { expect(webSocketServer.clients[client.id]).toBeDefined() }) + beforeEach(() => { + Identity.Identities = {} + }) + it('should automatically disconnect, if no handshake and player data gets received in timeout interval', () => { jest.advanceTimersByTime(CONNECTION_TIMEOUT) @@ -249,7 +256,7 @@ describe('Client', () => { data: { messageType: ClientServer.MessageType.CHAT, chat: { - chatType: Chat.ChatType.GLOBAL, + chatType: Chat.ChatType.COMMAND, message: SPAM_NOTIFICATION_MESSAGE(warningLevelMuteMapping[warningLevel]) } } From b354fe108698aff2ad82f4a44cccb6ab07134c15 Mon Sep 17 00:00:00 2001 From: Mario Reder Date: Tue, 3 Jul 2018 07:26:38 +0200 Subject: [PATCH 3/3] chore: ESLint Jest --- .eslintrc | 6 ++++-- package.json | 1 + yarn.lock | 4 ++++ 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.eslintrc b/.eslintrc index d44e78f..0aa2d09 100644 --- a/.eslintrc +++ b/.eslintrc @@ -1,11 +1,13 @@ { "parser": "typescript-eslint-parser", "extends": [ - "standard-with-typescript" + "standard-with-typescript", + "plugin:jest/recommended" ], "plugins": [ "typescript", - "jsdoc" + "jsdoc", + "jest" ], "rules": { "indent": "off", diff --git a/package.json b/package.json index b98269d..a4551cc 100644 --- a/package.json +++ b/package.json @@ -73,6 +73,7 @@ "eslint-config-standard": "^11.0.0", "eslint-config-standard-with-typescript": "^2.0.1", "eslint-plugin-import": "^2.8.0", + "eslint-plugin-jest": "^21.17.0", "eslint-plugin-jsdoc": "^3.4.1", "eslint-plugin-node": "^6.0.0", "eslint-plugin-promise": "^3.6.0", diff --git a/yarn.lock b/yarn.lock index d07b1af..851f51b 100644 --- a/yarn.lock +++ b/yarn.lock @@ -2531,6 +2531,10 @@ eslint-plugin-import@~2.2.0: minimatch "^3.0.3" pkg-up "^1.0.0" +eslint-plugin-jest@^21.17.0: + version "21.17.0" + resolved "https://registry.yarnpkg.com/eslint-plugin-jest/-/eslint-plugin-jest-21.17.0.tgz#fdb00e2f9ff16987d6ebcf2c75c7add105760bbb" + eslint-plugin-jsdoc@^3.4.1: version "3.4.1" resolved "https://registry.yarnpkg.com/eslint-plugin-jsdoc/-/eslint-plugin-jsdoc-3.4.1.tgz#aea72244a71dcffa3524615f661478f01bbbd826"