mirror of
https://github.com/actions/stale.git
synced 2025-12-27 10:48:18 +00:00
* feat(logs): enhance the logs and add a prefix with the issue number * chore: use camelCase for constants use the new logger for the new code due to the rebase
74 lines
1.7 KiB
TypeScript
74 lines
1.7 KiB
TypeScript
import {Logger} from './logger';
|
|
import * as core from '@actions/core';
|
|
|
|
describe('Logger', (): void => {
|
|
let logger: Logger;
|
|
|
|
beforeEach((): void => {
|
|
logger = new Logger();
|
|
});
|
|
|
|
describe('warning()', (): void => {
|
|
let message: string;
|
|
|
|
let coreWarningSpy: jest.SpyInstance;
|
|
|
|
beforeEach((): void => {
|
|
message = 'dummy-message';
|
|
|
|
coreWarningSpy = jest.spyOn(core, 'warning').mockImplementation();
|
|
});
|
|
|
|
it('should log a warning with the given message', (): void => {
|
|
expect.assertions(2);
|
|
|
|
logger.warning(message);
|
|
|
|
expect(coreWarningSpy).toHaveBeenCalledTimes(1);
|
|
expect(coreWarningSpy).toHaveBeenCalledWith('dummy-message');
|
|
});
|
|
});
|
|
|
|
describe('info()', (): void => {
|
|
let message: string;
|
|
|
|
let coreInfoSpy: jest.SpyInstance;
|
|
|
|
beforeEach((): void => {
|
|
message = 'dummy-message';
|
|
|
|
coreInfoSpy = jest.spyOn(core, 'info').mockImplementation();
|
|
});
|
|
|
|
it('should log an information with the given message', (): void => {
|
|
expect.assertions(2);
|
|
|
|
logger.info(message);
|
|
|
|
expect(coreInfoSpy).toHaveBeenCalledTimes(1);
|
|
expect(coreInfoSpy).toHaveBeenCalledWith('dummy-message');
|
|
});
|
|
});
|
|
|
|
describe('error()', (): void => {
|
|
let message: string;
|
|
|
|
let coreErrorSpy: jest.SpyInstance;
|
|
|
|
beforeEach((): void => {
|
|
message = 'dummy-message';
|
|
|
|
coreErrorSpy = jest.spyOn(core, 'error').mockImplementation();
|
|
});
|
|
|
|
it('should log an error with the given message', (): void => {
|
|
expect.assertions(2);
|
|
|
|
logger.error(message);
|
|
|
|
expect(coreErrorSpy).toHaveBeenCalledTimes(1);
|
|
expect(coreErrorSpy).toHaveBeenCalledWith('dummy-message');
|
|
});
|
|
});
|
|
});
|