Added newsletter slug generation to mirage

This commit is contained in:
Simon Backx 2022-06-02 13:19:52 +02:00
parent 7c04c2c472
commit 549e8c526f
2 changed files with 8 additions and 2 deletions

View File

@ -1,4 +1,6 @@
import {camelize} from '@ember/string';
import {dasherize} from '@ember/string';
import {isBlank} from '@ember/utils';
import {paginatedResponse} from '../utils';
export default function mockNewsletters(server) {
@ -12,6 +14,10 @@ export default function mockNewsletters(server) {
const senderEmail = attrs.senderEmail;
attrs.senderEmail = null;
if (isBlank(attrs.slug) && !isBlank(attrs.name)) {
attrs.slug = dasherize(attrs.name);
}
const newsletter = newsletters.create(attrs);
// workaround for mirage output of meta

View File

@ -153,7 +153,7 @@ describe('Acceptance: Settings - Newsletters', function () {
await checkSave({});
expect(findAll('[data-test-newsletter]').length, 'Total newsletters shown').to.equal(2);
expect(findAll('[data-test-newsletter]').length, 'Total newsletters shown afterwards').to.equal(2);
});
it('validates create newsletter before saving', async function () {
@ -174,7 +174,7 @@ describe('Acceptance: Settings - Newsletters', function () {
// Everything should be valid
await checkSave({});
expect(findAll('[data-test-newsletter]').length, 'Total newsletters shown').to.equal(2);
expect(findAll('[data-test-newsletter]').length, 'Total newsletters shown afterwards').to.equal(2);
});
it('checks limits when creating a newsletter', async function () {