mirror of
https://github.com/graphql-hive/console
synced 2026-05-21 08:08:52 +00:00
71 lines
1.3 KiB
TypeScript
71 lines
1.3 KiB
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,
|
|
},
|
|
});
|
|
|
|
const result = await hive
|
|
.info()
|
|
.then(() => 'OK')
|
|
.catch(() => 'ERROR');
|
|
|
|
expect(logger.info).not.toBeCalled();
|
|
expect(result).toBe('OK');
|
|
});
|
|
|
|
test('should not throw exception about missing token when disabled', async () => {
|
|
const logger = {
|
|
error: jest.fn(),
|
|
info: jest.fn(),
|
|
};
|
|
|
|
const hive = createHive({
|
|
enabled: false,
|
|
debug: false,
|
|
agent: {
|
|
logger,
|
|
},
|
|
});
|
|
|
|
const result = await hive
|
|
.info()
|
|
.then(() => 'OK')
|
|
.catch(() => 'ERROR');
|
|
|
|
expect(logger.info).not.toBeCalled();
|
|
expect(result).toBe('OK');
|
|
});
|