From 3b0306b0f09d79426c117784092701e1a4d8133c Mon Sep 17 00:00:00 2001 From: destruc7i0n Date: Mon, 3 Jan 2022 16:08:32 -0500 Subject: added tests --- tests/MinecraftHandler.test.ts | 47 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) create mode 100644 tests/MinecraftHandler.test.ts (limited to 'tests/MinecraftHandler.test.ts') diff --git a/tests/MinecraftHandler.test.ts b/tests/MinecraftHandler.test.ts new file mode 100644 index 0000000..4bb10f4 --- /dev/null +++ b/tests/MinecraftHandler.test.ts @@ -0,0 +1,47 @@ +import MinecraftHandler from '../src/MinecraftHandler' + +import { defaultConfig } from './constants' + +describe('MinecraftHandler', () => { + test('parses player join connection stat', () => { + const handler = new MinecraftHandler(defaultConfig) + + const { message } = handler['parseLogLine']('[Server thread/INFO]: destruc7i0n joined the game')! + + expect(message).toBe('destruc7i0n joined the game') + }) + + test('parses player leave connection stat', () => { + const handler = new MinecraftHandler(defaultConfig) + + const { message } = handler['parseLogLine']('[Server thread/INFO]: destruc7i0n left the game')! + + expect(message).toBe('destruc7i0n left the game') + }) + + test('parses death messages', () => { + const handler = new MinecraftHandler(defaultConfig) + + const tests = [ + '[Server thread/INFO]: destruc7i0n drowned', + '[Server thread/INFO]: destruc7i0n died', + '[Server thread/INFO]: destruc7i0n experienced kinetic energy', + '[Server thread/INFO]: destruc7i0n blew up', + '[Server thread/INFO]: destruc7i0n hit the ground too hard', + '[Server thread/INFO]: destruc7i0n fell off a ladder', + '[Server thread/INFO]: destruc7i0n was squashed by a falling anvil', + '[Server thread/INFO]: destruc7i0n went off with a bang', + '[Server thread/INFO]: destruc7i0n tried to swim in lava', + '[Server thread/INFO]: destruc7i0n was slain by mcfunction', + '[Server thread/INFO]: destruc7i0n suffocated in a wall', + '[Server thread/INFO]: destruc7i0n fell out of the world', + '[Server thread/INFO]: destruc7i0n withered away', + ] + + for (const test of tests) { + const { message } = handler['parseLogLine'](test)! + + expect(message).toBe(test.replace('[Server thread/INFO]: ', '')) + } + }) +}) \ No newline at end of file -- cgit 1.4.1 p;follow=1'>libedit/sig.h (unfollow)
Commit message (Collapse)Author
2019-07-24Warn when date has changedJune McEnroe
2019-07-24Add whenJune McEnroe
When? Now.
2019-07-24Remove histedit from bitJune McEnroe