More tests.

This commit is contained in:
gaba
2016-12-12 15:38:28 -08:00
parent 83a7ffee6f
commit 0648b2b1c8
6 changed files with 74 additions and 20 deletions
+30 -1
View File
@@ -17,7 +17,8 @@ describe('/api/v1/assets', () => {
{
url: 'https://coralproject.net/news/asset1',
title: 'Asset 1',
description: 'term1'
description: 'term1',
id: '1'
},
{
url: 'https://coralproject.net/news/asset2',
@@ -82,4 +83,32 @@ describe('/api/v1/assets', () => {
});
describe('#put', () => {
it('should close the asset', function() {
const asset = Asset.findByUrl('http://test.com')
.then((asset) => {
expect(asset).to.have.property('closedAt')
.and.to.equal(null);
});
const today = Date.now();
return chai.request(app)
.put(`/api/v1/asset/${asset.id}/status`)
.set(passport.inject({roles: ['admin']}))
.send({closedAt: today})
.then((res) => {
expect(res).to.have.status(201);
Asset.findByUrl('http://test.com')
.then((asset) => {
expect(asset).to.have.property('isClosed')
.and.to.equal(true);
expect(asset).to.have.property('closedAt')
.and.to.not.equal(null);
});
});
});
});
});
+2 -4
View File
@@ -202,10 +202,8 @@ describe('/api/v1/comments', () => {
it('shouldn\'t create a comment when the asset has expired commenting', () => {
return Asset.create({
settings: {
closedAt: new Date().setDate(0),
closedMessage: 'tests said expired!'
}
closedAt: new Date().setDate(0),
closedMessage: 'tests said expired!'
})
.then((asset) => {
return chai.request(app)