fixed test

This commit is contained in:
Wyatt Johnson
2018-05-07 14:48:47 -06:00
parent 3024300a3f
commit 732ff98f9b
+20 -23
View File
@@ -1,15 +1,13 @@
const SettingsService = require('../../../services/settings');
const Settings = require('../../../services/settings');
const chai = require('chai');
const expect = chai.expect;
describe('services.SettingsService', () => {
beforeEach(() =>
SettingsService.init({ moderation: 'PRE', wordlist: ['donut'] })
);
beforeEach(() => Settings.init({ moderation: 'PRE', wordlist: ['donut'] }));
describe('#retrieve()', () => {
it('should have a moderation field defined', () => {
return SettingsService.retrieve().then(settings => {
return Settings.retrieve().then(settings => {
expect(settings)
.to.have.property('moderation')
.and.to.equal('PRE');
@@ -17,7 +15,7 @@ describe('services.SettingsService', () => {
});
it('should have two infoBox fields defined', () => {
return SettingsService.retrieve().then(settings => {
return Settings.retrieve().then(settings => {
expect(settings)
.to.have.property('infoBoxEnable')
.and.to.equal(false);
@@ -28,6 +26,17 @@ describe('services.SettingsService', () => {
});
});
describe('#select()', () => {
it('should have a moderation field defined and not wordlist', () => {
return Settings.select('moderation').then(settings => {
expect(settings)
.to.have.property('moderation')
.and.to.equal('PRE');
expect(settings).to.not.have.property('wordlist');
});
});
});
describe('#update()', () => {
it('should update the settings with a passed object', () => {
const mockSettings = {
@@ -35,7 +44,7 @@ describe('services.SettingsService', () => {
infoBoxEnable: true,
infoBoxContent: 'yeah',
};
return SettingsService.update(mockSettings).then(updatedSettings => {
return Settings.update(mockSettings).then(updatedSettings => {
expect(updatedSettings).to.be.an('object');
expect(updatedSettings)
.to.have.property('moderation')
@@ -51,32 +60,20 @@ describe('services.SettingsService', () => {
infoBoxEnable: true,
infoBoxContent: 'yeah',
};
await SettingsService.update(mockSettings);
await Settings.update(mockSettings);
const settings = await SettingsService.retrieve();
const settings = await Settings.retrieve();
settings.charCount = 500;
await SettingsService.update(settings.toObject());
await Settings.update(settings.toObject());
});
});
describe('#get', () => {
it('should return the moderation settings', () => {
return SettingsService.retrieve().then(({ moderation }) => {
return Settings.retrieve().then(({ moderation }) => {
expect(moderation).not.to.be.null;
});
});
});
describe('#merge', () => {
it('should merge a settings object and its overrides', () => {
return SettingsService.retrieve().then(settings => {
let ovrSett = { moderation: 'POST' };
settings.merge(ovrSett);
expect(settings).to.have.property('moderation', 'POST');
});
});
});
});