Skip to content

Instantly share code, notes, and snippets.

@rotemmiz
Last active February 22, 2018 00:04
Show Gist options
  • Save rotemmiz/0677c9b5967bedbe80527f8df52570cb to your computer and use it in GitHub Desktop.
Save rotemmiz/0677c9b5967bedbe80527f8df52570cb to your computer and use it in GitHub Desktop.
Detox: A Year in. Building It, Testing With It
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