-
-
Notifications
You must be signed in to change notification settings - Fork 630
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(logger): initOptions.debugOptionsFilter
- Loading branch information
Wes Johnson (Arcadia)
committed
May 22, 2024
1 parent
c8d9f7b
commit ad43db7
Showing
4 changed files
with
55 additions
and
1 deletion.
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,21 @@ | ||
import { describe, it, expect, beforeAll, vi } from 'vitest'; | ||
import i18next from '../../src/i18next.js'; | ||
import logger from '../../src/logger.js'; | ||
|
||
describe('i18next debug', () => { | ||
let logSpy; | ||
beforeAll(async () => { | ||
logSpy = vi.spyOn(logger, 'log'); | ||
await i18next.init({ | ||
foo: 'bar', | ||
debug: true, | ||
}); | ||
i18next.changeLanguage('en'); | ||
}); | ||
|
||
describe('init log options filtering', () => { | ||
it('logs a subset of the options object', () => { | ||
expect(logSpy).toHaveBeenCalledWith('initialized', i18next.options); | ||
}); | ||
}); | ||
}); |
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,22 @@ | ||
import { describe, it, expect, beforeAll, vi } from 'vitest'; | ||
import i18next from '../../src/i18next.js'; | ||
import logger from '../../src/logger.js'; | ||
|
||
describe('i18next debug', () => { | ||
let logSpy; | ||
beforeAll(async () => { | ||
logSpy = vi.spyOn(logger, 'log'); | ||
await i18next.init({ | ||
foo: 'bar', | ||
debug: true, | ||
debugOptionsFilter: (opt) => ({ namespaces: opt.ns.length }), | ||
}); | ||
i18next.changeLanguage('en'); | ||
}); | ||
|
||
describe('init log options filtering', () => { | ||
it('logs a subset of the options object', () => { | ||
expect(logSpy).toHaveBeenCalledWith('initialized', { namespaces: 1 }); | ||
}); | ||
}); | ||
}); |
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