-
Notifications
You must be signed in to change notification settings - Fork 1
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
feat: Passing objects #18
Merged
+139
−13
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
60b72d0
This is a suggsted fix for #15 for uncolord space between prefix and …
lisaychuang 56b0a86
fix: whitespace is styled properly, unstyled content is left unstyled…
lisaychuang 2eb5b89
feat: Added new feature for user to pass in objects using console.dir
lisaychuang 6dd5d57
Merge branch 'master' into passing-objects
lisaychuang 330a2ce
fix: added dir test in test-helpers
lisaychuang 42a47f7
Merge branch 'passing-objects' of github.com:lisaychuang/bite-log int…
lisaychuang File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Binary file not shown.
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,75 @@ | ||
import Logger, { Level } from 'bite-log'; | ||
import { logCountAssert, makeTestPrinter } from './test-helpers'; | ||
|
||
QUnit.module('Objects, arrays, functions, etc... should be loggable'); | ||
|
||
QUnit.test('I can log an object after my string message', assert => { | ||
const printer = makeTestPrinter(); | ||
const logger = new Logger(Level.debug, printer); // only warns and error | ||
|
||
logger.log('Here are some numbers. They are increasing', [1, 2, 3, 4]); | ||
logCountAssert( | ||
{ message: 'after a debug', assert, printer }, | ||
{ l: 1 } // one log message has been printed | ||
); | ||
|
||
assert.deepEqual( | ||
printer.messages, | ||
{ | ||
log: [['Here are some numbers. They are increasing']], | ||
dir: [[1, 2, 3, 4]], | ||
error: [], | ||
warn: [], | ||
debug: [] | ||
}, | ||
'The thing passed to console.log was a string followed by my array of numbers' | ||
); | ||
}); | ||
|
||
QUnit.test('Formatting is applied to the string', assert => { | ||
const printer = makeTestPrinter(); | ||
const logger = new Logger(Level.debug, printer); // only warns and error | ||
|
||
logger.red.log('Here are some numbers. They are increasing', [1, 2, 3, 4]); | ||
logCountAssert( | ||
{ message: 'after a debug', assert, printer }, | ||
{ l: 1 } // one log message has been printed | ||
); | ||
|
||
assert.deepEqual( | ||
printer.messages, | ||
{ | ||
log: [['%cHere are some numbers. They are increasing', 'color: red;']], | ||
dir: [[1, 2, 3, 4]], | ||
error: [], | ||
warn: [], | ||
debug: [] | ||
}, | ||
'The thing passed to console.log was a string followed by my array of numbers' | ||
); | ||
}); | ||
|
||
QUnit.test( | ||
'Formatting is applied to all strings passed to the logger', | ||
assert => { | ||
const printer = makeTestPrinter(); | ||
const logger = new Logger(Level.debug, printer); // only warns and error | ||
|
||
logger.red.log( | ||
'Here are some numbers ', | ||
[1, 2, 3, 4], | ||
'They are increasing' | ||
); | ||
logCountAssert( | ||
{ message: 'after a debug', assert, printer }, | ||
{ l: 1 } // one log message has been printed | ||
); | ||
|
||
// logger.red.txt('Here are some numbers. They are increasing') | ||
assert.deepEqual( | ||
printer.messages.log[0], | ||
['%cHere are some numbers They are increasing', 'color: red;'], | ||
'The thing passed to console.log was a string followed by my array of numbers' | ||
); | ||
} | ||
); |
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
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You're receiving dir as an argument here, but never make an assertion of how many times
logger.dir()
has been invoked. Just follow the same stuff you've set up for the other message counts below