Last active
February 22, 2018 00:04
-
-
Save rotemmiz/0677c9b5967bedbe80527f8df52570cb to your computer and use it in GitHub Desktop.
Detox: A Year in. Building It, Testing With It
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
class MockNotificationServer { | |
start({port}) { | |
this.app.post('/regiscribe', this.onRegiscribe.bind(this)); | |
this.app.post('/unsubscribe', this.onUnsubscribe.bind(this)); | |
this.server = this.app.listen(port); | |
} | |
reset() { | |
this.lastRegiscribe = {}; | |
this.lastUnsubscribe = {}; | |
} | |
onRegiscribe(req, res) { | |
this.lastRegiscribe = req; | |
res.json({ | |
installationId: 'MockInstallationId' | |
}); | |
} | |
onUnsubscribe(req, res) { | |
this.lastUnsubscribe = req; | |
res.send('ok'); | |
} | |
expectLastRegiscribe() { | |
return expect(this.lastRegiscribe.body); | |
} | |
expectLastUnsubscribe() { | |
return expect(this.lastUnsubscribe.body); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment