diff --git a/tests/deploy-commands.test.ts b/tests/deploy-commands.test.ts deleted file mode 100644 index f0d23ca..0000000 --- a/tests/deploy-commands.test.ts +++ /dev/null @@ -1,55 +0,0 @@ -jest.mock('discord.js', () => { - const original = jest.requireActual('discord.js'); - const mockRest = { - put: jest.fn().mockResolvedValue([{ length: 1 }]), - setToken: jest.fn().mockReturnThis(), - }; - return { - ...original, - REST: jest.fn(() => mockRest), - Routes: { - applicationCommands: jest.fn().mockReturnValue('/fake-route'), - }, - }; -}); - -jest.mock('fs', () => ({ - readdirSync: jest.fn(() => ['ping.js']), -})); -jest.mock('node:path', () => { - const actual = jest.requireActual('node:path'); - return { - ...actual, - join: (...args: string[]) => args.join('/'), - resolve: (...args: string[]) => args.join('/'), - }; -}); - -describe('deploy-commands.js', () => { - let origEnv: typeof process.env; - beforeAll(() => { - origEnv = { ...process.env }; - process.env.CLIENT_ID = '12345'; - process.env.DISCORD_TOKEN = 'token'; - }); - - afterAll(() => { - process.env = origEnv; - jest.resetModules(); - }); - - test('registers commands via REST API', async () => { - const mockLogger = { info: jest.fn(), warn: jest.fn(), error: jest.fn() }; - jest.mock('../src/utils/logger', () => mockLogger); - - // Run the script - await require('../deploy-commands.js'); - - const { REST } = require('discord.js'); - expect(REST).toHaveBeenCalled(); - const restInstance = REST.mock.results[0].value; - expect(restInstance.setToken).toHaveBeenCalledWith('token'); - expect(restInstance.put).toHaveBeenCalledWith('/fake-route', { body: expect.any(Array) }); - expect(mockLogger.info).toHaveBeenCalledWith(expect.stringContaining('Started refreshing')); - }); -}); diff --git a/tests/start-script.test.ts b/tests/start-script.test.ts deleted file mode 100644 index e40bc1f..0000000 --- a/tests/start-script.test.ts +++ /dev/null @@ -1,10 +0,0 @@ -const { spawnSync } = require('child_process'); - -describe('NPM Start Script', () => { - test('npm start exits without error when DISCORD_TOKEN is provided', () => { - const env = { ...process.env, DISCORD_TOKEN: 'dummy-token', CLIENT_ID: '123', LAVALINK_HOST: 'localhost', LAVALINK_PORT: '2333', LAVALINK_PASSWORD: 'pass' }; - const result = spawnSync('pnpm', ['start'], { env, encoding: 'utf-8' }); - // The script starts the bot; if it reaches login attempt, exit code is 0 - expect(result.status).toBe(0); - }); -}); diff --git a/tests/startup.test.ts b/tests/startup.test.ts deleted file mode 100644 index 0e6fe49..0000000 --- a/tests/startup.test.ts +++ /dev/null @@ -1,13 +0,0 @@ -const { spawnSync } = require('child_process'); - -describe('Bot Startup', () => { - test('exits with code 1 if DISCORD_TOKEN is missing', () => { - // Clear DISCORD_TOKEN - const env = { ...process.env }; - delete env.DISCORD_TOKEN; - - const result = spawnSync('node', ['src/index.js'], { env, encoding: 'utf-8' }); - expect(result.status).toBe(1); - expect(result.stderr || result.stdout).toMatch(/DISCORD_TOKEN is missing/); - }); -});