Last active
August 29, 2015 14:14
-
-
Save jsilvestre/f62391c20230b74404eb to your computer and use it in GitHub Desktop.
Mocking singleton without class
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
# If I mock markBroken, it's not used in stopApp because the mock wraps module.exports.markBroken but doesn't change the function itself | |
markBroken = module.exports.markBroken = (app, err) -> | |
# does something | |
module.exports.stopApp = (app) -> | |
manager = new AppManager | |
manager.stop app, (err, result) -> | |
return markBroken app, err if err | |
# I must do that in order to mock markBroken | |
module.exports.markBroken = (app, err) -> | |
# does something | |
module.exports.stopApp = (app) -> | |
manager = new AppManager | |
manager.stop app, (err, result) -> | |
return module.exports.markBroken app, err if err |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment