0
Fork 0
mirror of https://github.com/verdaccio/verdaccio.git synced 2024-12-23 22:27:34 -05:00
verdaccio/packages/logger/test/logger.spec.ts
Behrang Yarahmadi 13310814da
#2606 add prettier plugin sort imports (#2607)
* #2606 add prettier plugin sort imprts

* #2606 update pnpm-lock.yaml

* #2606 update eslint rules

* #2606 fixes website directory formatting

Co-authored-by: Ayush Sharma <ayush.sharma@trivago.com>
2021-10-29 17:33:05 +02:00

53 lines
1.2 KiB
TypeScript

import { warningUtils } from '@verdaccio/core';
import { logger, setup } from '../src';
const mockWarningUtils = jest.fn();
jest.mock('@verdaccio/core', () => {
const original = jest.requireActual('@verdaccio/core');
return {
warningUtils: {
...original.warningUtils,
emit: (...args) => {
mockWarningUtils(...args);
},
},
};
});
describe('logger', () => {
beforeEach(() => {
jest.clearAllMocks();
});
test.skip('should write message logger', () => {
jest.spyOn(process.stdout, 'write');
setup([
{
level: 'info',
},
]);
logger.info({ packageName: 'test' }, `publishing or updating a new version for @{packageName}`);
// FIXME: check expect
// expect(spyOn).toHaveBeenCalledTimes(2);
});
test('throw deprecation warning if multiple loggers configured', () => {
setup([
{
level: 'info',
},
{
level: 'http',
},
]);
expect(mockWarningUtils).toHaveBeenCalledWith(warningUtils.Codes.VERDEP002);
});
test('regression: do not throw deprecation warning if no logger config is provided', () => {
setup();
expect(mockWarningUtils).not.toHaveBeenCalled();
});
});