mirror of
https://github.com/TryGhost/Ghost.git
synced 2024-12-22 18:31:57 +03:00
5218cf194d
refs TryGhost/Team#1513 - nullable `sender_name` allows us to use auto fallback of site title for sender name without setting any explicit value for it.
36 lines
1.2 KiB
JavaScript
36 lines
1.2 KiB
JavaScript
/* eslint no-invalid-this:0 */
|
|
const errors = require('@tryghost/errors');
|
|
const sinon = require('sinon');
|
|
const should = require('should');
|
|
const models = require('../../../../core/server/models');
|
|
|
|
describe('Unit: models/newsletter', function () {
|
|
const mockDb = require('mock-knex');
|
|
|
|
before(function () {
|
|
models.init();
|
|
});
|
|
|
|
after(function () {
|
|
sinon.restore();
|
|
});
|
|
|
|
describe('validation', function () {
|
|
describe('blank', function () {
|
|
it('throws validation error for mandatory fields', function () {
|
|
return models.Newsletter.add({})
|
|
.then(function () {
|
|
throw new Error('expected ValidationError');
|
|
})
|
|
.catch(function (err) {
|
|
err.length.should.eql(2);
|
|
(err[0] instanceof errors.ValidationError).should.eql(true);
|
|
(err[1] instanceof errors.ValidationError).should.eql(true);
|
|
err[0].message.should.match(/newsletters\.name/);
|
|
err[1].message.should.match(/newsletters\.slug/);
|
|
});
|
|
});
|
|
});
|
|
});
|
|
});
|