mirror of
https://github.com/wkulhanek/bonob.git
synced 2025-12-21 17:33:29 +01:00
Ability to enable/disable reporting of now playing and scrobbling
This commit is contained in:
41
tests/config.test.ts
Normal file
41
tests/config.test.ts
Normal file
@@ -0,0 +1,41 @@
|
||||
import config from "../src/config";
|
||||
|
||||
describe("config", () => {
|
||||
const OLD_ENV = process.env;
|
||||
|
||||
beforeEach(() => {
|
||||
jest.resetModules();
|
||||
process.env = { ...OLD_ENV };
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
process.env = OLD_ENV;
|
||||
});
|
||||
|
||||
function describeBooleanConfigValue(name : string, envVar: string) {
|
||||
describe(name, () => {
|
||||
function expecting({
|
||||
value,
|
||||
expected,
|
||||
}: {
|
||||
value: string;
|
||||
expected: boolean;
|
||||
}) {
|
||||
describe(`when value is ${value}`, () => {
|
||||
it(`should be ${expected}`, () => {
|
||||
process.env[envVar] = value;
|
||||
expect((config() as any)[name]).toEqual(expected);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
expecting({ value: "", expected: true });
|
||||
expecting({ value: "true", expected: true });
|
||||
expecting({ value: "false", expected: false });
|
||||
expecting({ value: "foo", expected: false });
|
||||
});
|
||||
};
|
||||
|
||||
describeBooleanConfigValue("scrobbleTracks", "BONOB_SCROBBLE_TRACKS");
|
||||
describeBooleanConfigValue("reportNowPlaying", "BONOB_REPORT_NOW_PLAYING");
|
||||
});
|
||||
Reference in New Issue
Block a user