console/packages/libraries/client/tests/enabled.spec.ts
JYC c0e08216b0
fix: hide missing token warning when disabled (#260)
Co-authored-by: Kamil Kisiela <kamil.kisiela@gmail.com>
2022-08-03 11:39:57 +02:00

49 lines
920 B
TypeScript

import { createHive } from '../src/client';
test("should log that it's not enabled", async () => {
const logger = {
error: jest.fn(),
info: jest.fn(),
};
const hive = createHive({
enabled: false,
debug: true,
agent: {
logger,
},
token: '',
});
const result = await hive
.info()
.then(() => 'OK')
.catch(() => 'ERROR');
expect(logger.info).toHaveBeenCalledWith(expect.stringContaining(`[hive] is not enabled.`));
expect(result).toBe('OK');
});
test("should not log that it's not enabled", async () => {
const logger = {
error: jest.fn(),
info: jest.fn(),
};
const hive = createHive({
enabled: false,
debug: false,
agent: {
logger,
},
token: '',
});
const result = await hive
.info()
.then(() => 'OK')
.catch(() => 'ERROR');
expect(logger.info).not.toBeCalled();
expect(result).toBe('OK');
});