-
Notifications
You must be signed in to change notification settings - Fork 375
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logs): enhance the logs and add a prefix with the issue number
- Loading branch information
Showing
5 changed files
with
249 additions
and
31 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,78 @@ | ||
import {Issue} from '../IssueProcessor'; | ||
import {IssueLogger} from './issue-logger'; | ||
import * as core from '@actions/core'; | ||
|
||
describe('IssueLogger', (): void => { | ||
let issue: Issue; | ||
let issueLogger: IssueLogger; | ||
|
||
beforeEach((): void => { | ||
issue = { | ||
number: 8 | ||
} as Issue; | ||
issueLogger = new IssueLogger(issue); | ||
}); | ||
|
||
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 and with the issue number as prefix', (): void => { | ||
expect.assertions(2); | ||
|
||
issueLogger.warning(message); | ||
|
||
expect(coreWarningSpy).toHaveBeenCalledTimes(1); | ||
expect(coreWarningSpy).toHaveBeenCalledWith('[#8] 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 and with the issue number as prefix', (): void => { | ||
expect.assertions(2); | ||
|
||
issueLogger.info(message); | ||
|
||
expect(coreInfoSpy).toHaveBeenCalledTimes(1); | ||
expect(coreInfoSpy).toHaveBeenCalledWith('[#8] 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 and with the issue number as prefix', (): void => { | ||
expect.assertions(2); | ||
|
||
issueLogger.error(message); | ||
|
||
expect(coreErrorSpy).toHaveBeenCalledTimes(1); | ||
expect(coreErrorSpy).toHaveBeenCalledWith('[#8] dummy-message'); | ||
}); | ||
}); | ||
}); |
Oops, something went wrong.