mirror of
https://github.com/pieartsy/PluralFlux.git
synced 2026-04-16 17:45:28 +10:00
test: Increase test coverage (#39)
* test: Increase test coverage * Assert console.error on failed client.login test * Remove redundant removeMember test
This commit is contained in:
@@ -293,8 +293,23 @@ describe('bot', () => {
|
||||
expect(client.login).toHaveBeenCalledWith(process.env.FLUXER_BOT_TOKEN)
|
||||
})
|
||||
|
||||
test('login exits with code 1 if client.login fails', async () => {
|
||||
// Arrange
|
||||
let message = "client.login failed";
|
||||
client.login = jest.fn().mockImplementation(() => { throw new Error(message) });
|
||||
jest.spyOn(global.console, 'error').mockImplementation(() => {});
|
||||
jest.spyOn(process, 'exit').mockImplementation(() => {});
|
||||
// Act
|
||||
await login();
|
||||
// Assert
|
||||
expect(console.error).toHaveBeenCalledTimes(1);
|
||||
expect(console.error).toHaveBeenCalledWith('Login failed:', new Error(message));
|
||||
expect(process.exit).toHaveBeenCalledTimes(1);
|
||||
expect(process.exit).toHaveBeenCalledWith(1);
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
// restore the spy created with spyOn
|
||||
jest.restoreAllMocks();
|
||||
});
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user