fixing js tests

This commit is contained in:
Amine Ben hammou
2018-01-22 10:49:12 +00:00
parent f42b61a49e
commit 20d0ed1aac
2 changed files with 32 additions and 19 deletions

View File

@@ -93,27 +93,33 @@ define([
};
Module.saveTemplate = function (options) {
var categories = [
'saved',
App.getNewsletter().get('type')
];
var promise = jQuery.Deferred();
return Module.getThumbnail(
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
).then(function (thumbnail) {
var data = _.extend(options || {}, {
thumbnail: thumbnail.toDataURL('image/jpeg'),
body: JSON.stringify(App.getBody()),
categories: JSON.stringify(categories)
});
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletterTemplates',
action: 'save',
data: data
});
promise.then(function (thumbnail) {
var data = _.extend(options || {}, {
thumbnail: thumbnail.toDataURL('image/jpeg'),
body: JSON.stringify(App.getBody()),
categories: JSON.stringify([
'saved',
App.getNewsletter().get('type')
])
});
return MailPoet.Ajax.post({
api_version: window.mailpoet_api_version,
endpoint: 'newsletterTemplates',
action: 'save',
data: data
});
});
Module.getThumbnail(
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
).then(function (thumbnail) {
promise.resolve(thumbnail);
});
return promise;
};
Module.exportTemplate = function (options) {