Skip to content

Instantly share code, notes, and snippets.

@spirinvladimir
Last active August 29, 2017 05:15
Show Gist options
  • Save spirinvladimir/9c843ec54561033655dbf7d21aa83eed to your computer and use it in GitHub Desktop.
Save spirinvladimir/9c843ec54561033655dbf7d21aa83eed to your computer and use it in GitHub Desktop.
test.cb('PUT /api/stocks/1 (update the price of a single stock)', t => {
const
app = webserver(createList(), port());
request(app)
.post('/api/stocks')
.send({name: 'EUR', currentPrice: 1})
.expect(200)
.then(res => res.body.id)
.then(id => request(app)
.put('/api/stocks/' + id)
.send({currentPrice: 2})
.set('Accept', 'application/json')
.expect(200))
.then(() => id)
.then(id => request(app)
.get('/api/stocks/' + id)
.set('Accept', 'application/json')
.expect(200))
.then(res => res.body.currentPrice)
.then((currentPrice) => {
app.close();
t.deepEqual(currentPrice, 2);
t.end();
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment