mirror of
https://github.com/wassname/talk.git
synced 2026-07-23 13:10:20 +08:00
Added asset settings + improved tests for routes
This commit is contained in:
+27
-1
@@ -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')
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user