Added asset settings + improved tests for routes

This commit is contained in:
Wyatt Johnson
2016-11-29 10:01:52 -07:00
parent 735f2d09ad
commit ac17fc2cc6
13 changed files with 401 additions and 407 deletions
+27 -1
View File
@@ -1,5 +1,10 @@
const Asset = require('../../models/asset');
const expect = require('chai').expect;
const chai = require('chai');
const expect = chai.expect;
// Use the chai should.
chai.should();
describe('Asset: model', () => {
@@ -53,6 +58,27 @@ describe('Asset: model', () => {
});
});
describe('#overrideSettings', () => {
it('should update the settings', () => {
return Asset
.findOrCreateByUrl('https://override.test.com/asset')
.then((asset) => {
expect(asset).to.have.property('settings');
expect(asset.settings).to.be.null;
return Asset.overrideSettings(asset.id, {moderation: 'pre'});
})
.then(() => {
return Asset.findOrCreateByUrl('https://override.test.com/asset');
})
.then((asset) => {
expect(asset).to.have.property('settings');
expect(asset.settings).is.an('object');
expect(asset.settings).to.have.property('moderation', 'pre');
});
});
});
describe('#findOrCreateByUrl', ()=> {
it('should find an asset by a url', () => {
return Asset.findOrCreateByUrl('http://test.com')
+2
View File
@@ -14,6 +14,7 @@ describe('Setting: model', () => {
expect(settings).to.have.property('moderation').and.to.equal('pre');
});
});
it('should have two infoBox fields defined', () => {
return Setting.getSettings().then(settings => {
expect(settings).to.have.property('infoBoxEnable').and.to.equal(false);
@@ -26,6 +27,7 @@ describe('Setting: model', () => {
it('should update the settings with a passed object', () => {
const mockSettings = {moderation: 'post', infoBoxEnable: true, infoBoxContent: 'yeah'};
return Setting.updateSettings(mockSettings).then(updatedSettings => {
expect(updatedSettings).to.be.an('object');
expect(updatedSettings).to.have.property('moderation').and.to.equal('post');
expect(updatedSettings).to.have.property('infoBoxEnable', true);
expect(updatedSettings).to.have.property('infoBoxContent', 'yeah');