This commit is contained in:
@@ -29,6 +29,9 @@ jobs:
|
|||||||
- name: Run spellcheck
|
- name: Run spellcheck
|
||||||
run: bun run check:spell
|
run: bun run check:spell
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: bun test:unit
|
||||||
|
|
||||||
build_and_push:
|
build_and_push:
|
||||||
name: Build and push
|
name: Build and push
|
||||||
strategy:
|
strategy:
|
||||||
|
|||||||
@@ -23,3 +23,6 @@ jobs:
|
|||||||
|
|
||||||
- name: Run spellcheck
|
- name: Run spellcheck
|
||||||
run: bun run check:spell
|
run: bun run check:spell
|
||||||
|
|
||||||
|
- name: Run tests
|
||||||
|
run: bun test:unit
|
||||||
|
|||||||
@@ -3,6 +3,7 @@
|
|||||||
"build": "bun build --minify --target bun --outdir dist --sourcemap src/app.ts",
|
"build": "bun build --minify --target bun --outdir dist --sourcemap src/app.ts",
|
||||||
"check:code": "eslint src/ --ext .ts",
|
"check:code": "eslint src/ --ext .ts",
|
||||||
"check:spell": "cspell --config cspell.code.json **/*.ts",
|
"check:spell": "cspell --config cspell.code.json **/*.ts",
|
||||||
|
"test:unit": "bun test",
|
||||||
"start": "bun run src/app.ts"
|
"start": "bun run src/app.ts"
|
||||||
},
|
},
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
|
|||||||
22
src/app.test.ts
Normal file
22
src/app.test.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { test, expect } from "bun:test";
|
||||||
|
import { getModes } from "./app";
|
||||||
|
|
||||||
|
test("getModes", () => {
|
||||||
|
test("defaults to false", () => {
|
||||||
|
expect(getModes([])).toEqual({
|
||||||
|
connect: false,
|
||||||
|
disconnect: false,
|
||||||
|
moved: false,
|
||||||
|
message: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
test("modes are true if set in input", () => {
|
||||||
|
expect(getModes(["connect", "moved"])).toEqual({
|
||||||
|
connect: true,
|
||||||
|
disconnect: false,
|
||||||
|
moved: false,
|
||||||
|
message: false,
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
12
src/app.ts
12
src/app.ts
@@ -36,11 +36,15 @@ const gotifyConfig = {
|
|||||||
title: GOTIFY_TITLE,
|
title: GOTIFY_TITLE,
|
||||||
};
|
};
|
||||||
|
|
||||||
function getModes(): {
|
export function getModes(modeInput: Mode[]): {
|
||||||
[key in Mode]: boolean;
|
[key in Mode]: boolean;
|
||||||
} {
|
} {
|
||||||
const modes = MODE.map((mode) => {
|
const modes = modeInput
|
||||||
|
.map((mode) => {
|
||||||
return { [mode]: true };
|
return { [mode]: true };
|
||||||
|
})
|
||||||
|
.reduce((acc, cur) => {
|
||||||
|
return { ...acc, ...cur };
|
||||||
});
|
});
|
||||||
|
|
||||||
return {
|
return {
|
||||||
@@ -87,11 +91,11 @@ TeamSpeak.connect({
|
|||||||
password: TS3_PASSWORD,
|
password: TS3_PASSWORD,
|
||||||
nickname: TS3_NICKNAME,
|
nickname: TS3_NICKNAME,
|
||||||
}).then((teamspeak) => {
|
}).then((teamspeak) => {
|
||||||
const mode = getModes();
|
const mode = getModes(MODE);
|
||||||
|
|
||||||
logger.info(
|
logger.info(
|
||||||
`connected to TS3 in modes: ${Object.entries(mode)
|
`connected to TS3 in modes: ${Object.entries(mode)
|
||||||
.filter(([_, value]) => value)
|
.filter(([, value]) => value)
|
||||||
.map(([key]) => key)
|
.map(([key]) => key)
|
||||||
.join(", ")}`
|
.join(", ")}`
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user