diff --git a/.eslintrc.json b/.eslintrc.json index bfe6d12..06c6d2e 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -2,5 +2,5 @@ "root": true, "parser": "@typescript-eslint/parser", "plugins": ["@typescript-eslint"], - "extends": ["prettier", "plugin:prettier/recommended"] + "extends": ["prettier"] } diff --git a/__tests__/discord-client.test.ts b/__tests__/discord-client.test.ts index 33783ff..a8eade1 100644 --- a/__tests__/discord-client.test.ts +++ b/__tests__/discord-client.test.ts @@ -51,7 +51,7 @@ describe("DiscordClient", () => { describe("isValidChannel", () => { test("returns true if the channel is not empty", () => { - const input = "channel name"; + const input = "123456789012345678"; const output = true; expect(discordClient.isValidChannel(input)).toEqual(output); }); diff --git a/config/jest.setup.js b/config/jest.setup.js new file mode 100644 index 0000000..81b5fe7 --- /dev/null +++ b/config/jest.setup.js @@ -0,0 +1,8 @@ +module.exports = async () => { + const CHANNEL_CHANGELOG = "123456789012345678"; + const CHANNEL_MAIN = "876543210987654321"; + process.env = Object.assign(process.env, { + CHANGELOG_CHANNEL: CHANNEL_CHANGELOG, + CHANNEL: CHANNEL_MAIN, + }); +}; diff --git a/jest.config.js b/jest.config.js index dc9d869..77005ee 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,5 +1,5 @@ module.exports = { preset: "ts-jest", testEnvironment: "node", - setupFiles: ["dotenv/config"], + globalSetup: "./config/jest.setup.js", }; diff --git a/src/DiscordClient.ts b/src/DiscordClient.ts index 243c0a3..14fc043 100644 --- a/src/DiscordClient.ts +++ b/src/DiscordClient.ts @@ -34,9 +34,8 @@ class DiscordClient extends Client { }; isValidChannel = (channelName: string): boolean => { - // since they are environment variables, we can only really check that - // they are not empty - return channelName.length > 0; + // channel ids seem to always be 18 length + return channelName.length === 18; }; }