-
Notifications
You must be signed in to change notification settings - Fork 5
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 #84 from KCarlile/73-add-a-test-suite
Issue #73: Add Jest test suite for unit/regression testing. One examp…
- Loading branch information
Showing
9 changed files
with
6,091 additions
and
3 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
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,5 @@ | ||
class Controller { | ||
constructor() { | ||
|
||
} | ||
} |
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,91 @@ | ||
/** | ||
* Logger class provides an easy way to log to Chrome's console and includes section dividers. | ||
* | ||
* Tested via /tests/Logger.test.js. | ||
*/ | ||
module.exports = class Logger { | ||
enabled = false; | ||
|
||
/** | ||
* Default constructor assumes debugging to be disabled. | ||
* | ||
* @param {boolean} enabled | ||
*/ | ||
constructor(enabled) { | ||
this.enabled = enabled; | ||
} | ||
|
||
/** | ||
* Response with true if logging is enabled, false if logging is disabled. | ||
* | ||
* @returns {boolean} Status of logging enablement. | ||
*/ | ||
isEnabled() { | ||
return this.enabled; | ||
} | ||
|
||
/** | ||
* Enables logging even if Logger was instantiated with logging disabled. | ||
*/ | ||
enableLogging() { | ||
this.enabled = true; | ||
} | ||
|
||
/** | ||
* Disables logging even if Logger was instantiated with logging enabled. | ||
*/ | ||
disableLogging() { | ||
this.enabled = false; | ||
} | ||
|
||
/** | ||
* Logs a message to the console if debugging is enabled. | ||
* | ||
* @param {string} message The message to be written to console.log(). | ||
* @param {boolean} override Overrides the instance-level setting for logging enabled. | ||
* @returns {boolean} True if the console.log() command succeeded; false if not. | ||
*/ | ||
logger(message, override = false) { | ||
let success = false; | ||
|
||
if (this.enabled || override) { | ||
try { | ||
console.log(message); | ||
|
||
success = true; | ||
} | ||
catch (exception) { | ||
throw "Console.log not available." | ||
} | ||
} | ||
|
||
return success; | ||
} | ||
|
||
/** | ||
* Prints a new section divider to the console if logging is enabled. | ||
* | ||
* @param {boolean} override | ||
* @param {boolean} override Overrides the instance-level setting for logging enabled. | ||
* @returns {boolean} True if the console.log() command succeeded; false if not. | ||
*/ | ||
loggerNewSection(override = false) { | ||
return this.logger("==========", override); | ||
} | ||
|
||
// start a new sub-block of logging with a light line if logging is enabled | ||
|
||
/** | ||
* Prints a sub-block divider line to the console if logging is enabled. | ||
* @param {boolean} override Overrides the instance-level setting for logging enabled. | ||
* @returns {boolean} True if the console.log() command succeeded; false if not. | ||
*/ | ||
/** | ||
* | ||
* @param {*} override | ||
* @returns | ||
*/ | ||
loggerNewBlock(override = false) { | ||
return this.logger("----------", override); | ||
} | ||
} |
Oops, something went wrong.