Skip to content

Instantly share code, notes, and snippets.

@boo1ean
Created September 14, 2014 19:20
Show Gist options
  • Save boo1ean/e73b7d02bbb618904f94 to your computer and use it in GitHub Desktop.
Save boo1ean/e73b7d02bbb618904f94 to your computer and use it in GitHub Desktop.
var t = require('yartf');
var credentials = {
email: 'admin@example.com',
password: 'test'
};
var task = {
title: 'First task'
};
var url = 'http://localhost:3000';
var login = t(url)
.post('/login', credentials)
.as('login')
.assert(function() {
this.res.login.status.should.be(200);
this.res.login.body.errors.should.not.be.ok;
});
var logout = t(url)
.get('/logout')
.as('/logout')
.assert(function() {
this.res.logout.status.should.be(200);
});
var taskCreateAndGet = t(url)
.use(login)
.post('/tasks', task)
.get('/tasks/1')
.as('task')
.assert(function() {
this.res.task.id.should.be.exactly(1);
this.res.task.title.should.be.exactly(task.title);
})
.use(logout);
it('Should create task', function(done) {
taskCreateAndGet.exec(done);
}):
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment