Created
September 14, 2014 19:20
-
-
Save boo1ean/e73b7d02bbb618904f94 to your computer and use it in GitHub Desktop.
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
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