Repository navigation
feat: Return namespaces string when invoking disable() #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -81,4 +81,43 @@ describe('debug', () => { | |
| expect(logBar.namespace).to.be.equal('foobar'); | ||
| }); | ||
| }); | ||
|
|
||
| describe('rebuild namespaces string (disable)', () => { | ||
| it('handle names, skips, and wildcards', () => { | ||
| debug.enable('test,abc*,-abc'); | ||
| const namespaces = debug.disable(); | ||
| expect(namespaces).to.equal('test,abc*,-abc'); | ||
| }); | ||
|
|
||
| it('handles empty', () => { | ||
| debug.enable(''); | ||
| const namespaces = debug.disable(); | ||
| expect(namespaces).to.equal(''); | ||
| expect(debug.names).to.deep.equal([]); | ||
| expect(debug.skips).to.deep.equal([]); | ||
| }); | ||
|
|
||
| it('handles all', () => { | ||
| debug.enable('*'); | ||
| const namespaces = debug.disable(); | ||
| expect(namespaces).to.equal('*'); | ||
| }); | ||
|
|
||
| it('handles skip all', () => { | ||
| debug.enable('-*'); | ||
| const namespaces = debug.disable(); | ||
| expect(namespaces).to.equal('-*'); | ||
| }); | ||
|
|
||
| it('names+skips same with new string', () => { | ||
| debug.enable('test,abc*,-abc'); | ||
| const oldNames = [...debug.names]; | ||
| const oldSkips = [...debug.skips]; | ||
| const namespaces = debug.disable(); | ||
| expect(namespaces).to.equal('test,abc*,-abc'); | ||
| debug.enable(namespaces); | ||
| expect(oldNames.map(String)).to.deep.equal(debug.names.map(String)); | ||
| expect(oldSkips.map(String)).to.deep.equal(debug.skips.map(String)); | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why the
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. They are RegExp objects, so they are not the same even though the regular expression is the same. Mapping to their string representation will make the chai deep equal happy.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, sounds good. |
||
| }); | ||
| }); | ||
| }); | ||
Uh oh!
There was an error while loading. Please reload this page.