Ghost/test/unit/server/models/newsletter.test.js
Rishabh Garg 5218cf194d
Updated newsletter sender name column as nullable (#14476)
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.
2022-04-14 17:42:20 +05:30

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/);
});
});
});
});
});