2013-09-06 20:07:25 +04:00
|
|
|
/*globals describe, before, beforeEach, afterEach, it */
|
|
|
|
var testUtils = require('./testUtils'),
|
|
|
|
should = require('should'),
|
2013-10-08 05:39:33 +04:00
|
|
|
_ = require('underscore');
|
2013-09-06 20:07:25 +04:00
|
|
|
|
2013-10-08 05:39:33 +04:00
|
|
|
describe('Post API', function () {
|
2013-06-25 15:43:15 +04:00
|
|
|
|
2013-10-08 05:39:33 +04:00
|
|
|
var user = testUtils.DataGenerator.forModel.users[0],
|
|
|
|
authCookie;
|
2013-08-25 00:51:58 +04:00
|
|
|
|
|
|
|
before(function (done) {
|
2013-10-08 05:39:33 +04:00
|
|
|
testUtils.clearData()
|
|
|
|
.then(function () {
|
|
|
|
done();
|
|
|
|
}, done);
|
2013-08-25 00:51:58 +04:00
|
|
|
});
|
2013-06-25 15:43:15 +04:00
|
|
|
|
|
|
|
beforeEach(function (done) {
|
2013-08-25 00:51:58 +04:00
|
|
|
this.timeout(5000);
|
2013-09-06 20:07:25 +04:00
|
|
|
testUtils.initData()
|
2013-08-25 00:51:58 +04:00
|
|
|
.then(function () {
|
2013-10-08 05:39:33 +04:00
|
|
|
return testUtils.insertDefaultFixtures();
|
2013-08-25 00:51:58 +04:00
|
|
|
})
|
|
|
|
.then(function () {
|
2013-10-08 05:39:33 +04:00
|
|
|
return testUtils.API.login(user.email, user.password);
|
|
|
|
})
|
|
|
|
.then(function (authResponse) {
|
|
|
|
authCookie = authResponse;
|
|
|
|
|
2013-08-25 00:51:58 +04:00
|
|
|
done();
|
|
|
|
}, done);
|
|
|
|
});
|
|
|
|
|
|
|
|
afterEach(function (done) {
|
2013-09-06 20:07:25 +04:00
|
|
|
testUtils.clearData().then(function () {
|
2013-06-25 15:43:15 +04:00
|
|
|
done();
|
|
|
|
}, done);
|
|
|
|
});
|
|
|
|
|
2013-10-08 05:39:33 +04:00
|
|
|
it('can retrieve a post', function (done) {
|
|
|
|
testUtils.API.get(testUtils.API.ApiRouteBase + 'posts/?status=all', authCookie).then(function (result) {
|
2013-08-25 00:51:58 +04:00
|
|
|
should.exist(result);
|
2013-10-08 05:39:33 +04:00
|
|
|
should.exist(result.response);
|
|
|
|
result.response.posts.length.should.be.above(1);
|
2013-08-30 08:18:55 +04:00
|
|
|
done();
|
|
|
|
}).otherwise(done);
|
|
|
|
});
|
|
|
|
|
2013-07-04 23:53:45 +04:00
|
|
|
});
|