mirror of
https://github.com/wassname/talk.git
synced 2026-09-09 11:38:08 +08:00
More tests.
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user