Fixed default mobiledoc handling in our data generator

no issue

- the handling here was not correct
- if you've passed no mobiledoc, it wasn't adding mobiledoc and an undefined html value
- we need a default mobiledoc+html value in case you don't pass the values within the test cases
This commit is contained in:
kirrg001 2018-02-21 23:44:58 +01:00
parent d32cea479e
commit 3dedfc7d61

View File

@ -410,14 +410,22 @@ DataGenerator.forKnex = (function () {
overrides = overrides || {};
var newObj = _.cloneDeep(overrides),
mobiledoc = JSON.parse(overrides.mobiledoc || '{}');
mobiledocObj;
if (!newObj.mobiledoc) {
newObj.mobiledoc = DataGenerator.markdownToMobiledoc('## markdown');
}
if (!newObj.html) {
mobiledocObj = JSON.parse(newObj.mobiledoc);
newObj.html = mobiledocObj.cards && mobiledocObj.cards[0][1].markdown;
}
return _.defaults(newObj, {
id: ObjectId.generate(),
uuid: uuid.v4(),
title: 'title',
status: 'published',
html: mobiledoc.cards && mobiledoc.cards[0][1].markdown,
featured: true,
page: false,
author_id: DataGenerator.Content.users[0].id,