This repository has been archived by the owner on Oct 18, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #271 from SuperViz/chore/logger-config
chore(debug-config): remove default logger and implement logger by namespace
- Loading branch information
Showing
14 changed files
with
102 additions
and
110 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
import doRequest from './do-request'; | ||
import logger from './logger'; | ||
import { Logger } from './logger'; | ||
import { Observer } from './observer'; | ||
|
||
export { logger, doRequest, Observer }; | ||
export { Logger, doRequest, Observer }; |
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 |
---|---|---|
@@ -1,43 +1,33 @@ | ||
import debug from 'debug'; | ||
|
||
import { Debug } from './logger'; | ||
import { Logger } from './logger'; | ||
|
||
jest.mock('debug'); | ||
|
||
describe('Debug', () => { | ||
let debugInstance: Debug; | ||
describe('Logger', () => { | ||
let debugInstance: Logger; | ||
let mockDebug: jest.MockedFunction<debug.Debugger>; | ||
|
||
beforeEach(() => { | ||
mockDebug = jest.fn() as unknown as jest.MockedFunction<debug.Debugger>; | ||
(debug as jest.MockedFunction<typeof debug>).mockReturnValue(mockDebug); | ||
debugInstance = new Debug('@superviz/sdk'); | ||
debugInstance = new Logger('@superviz/sdk'); | ||
}); | ||
|
||
afterEach(() => { | ||
jest.restoreAllMocks(); | ||
}); | ||
|
||
it('should create a new instance of Debug', () => { | ||
test('should create a new instance of Debug', () => { | ||
expect(debugInstance).toBeDefined(); | ||
}); | ||
|
||
it('should call debug with the correct scope on initialization', () => { | ||
test('should call debug with the correct scope on initialization', () => { | ||
expect(debug).toHaveBeenCalledWith('@superviz/sdk'); | ||
}); | ||
|
||
it('should call debug with the correct arguments on log', () => { | ||
test('should call debug with the correct arguments on log', () => { | ||
debugInstance.log('test-message', 123, { foo: 'bar' }); | ||
expect(mockDebug).toHaveBeenCalledWith('test-message', 123, { foo: 'bar' }); | ||
}); | ||
|
||
it('should call debug.enable with the correct prefix on enable', () => { | ||
debugInstance.enable('test-prefix'); | ||
expect(debug.enable).toHaveBeenCalledWith('test-prefix'); | ||
}); | ||
|
||
it('should call debug.disable on disable', () => { | ||
debugInstance.disable(); | ||
expect(debug.disable).toHaveBeenCalled(); | ||
}); | ||
}); |
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
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
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
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
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
Oops, something went wrong.