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,18 +93,16 @@ define([
}; };
Module.saveTemplate = function (options) { Module.saveTemplate = function (options) {
var categories = [ var promise = jQuery.Deferred();
'saved',
App.getNewsletter().get('type')
];
return Module.getThumbnail( promise.then(function (thumbnail) {
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
).then(function (thumbnail) {
var data = _.extend(options || {}, { var data = _.extend(options || {}, {
thumbnail: thumbnail.toDataURL('image/jpeg'), thumbnail: thumbnail.toDataURL('image/jpeg'),
body: JSON.stringify(App.getBody()), body: JSON.stringify(App.getBody()),
categories: JSON.stringify(categories) categories: JSON.stringify([
'saved',
App.getNewsletter().get('type')
])
}); });
return MailPoet.Ajax.post({ return MailPoet.Ajax.post({
@@ -114,6 +112,14 @@ define([
data: data data: data
}); });
}); });
Module.getThumbnail(
jQuery('#mailpoet_editor_content > .mailpoet_block').get(0)
).then(function (thumbnail) {
promise.resolve(thumbnail);
});
return promise;
}; };
Module.exportTemplate = function (options) { Module.exportTemplate = function (options) {

View File

@@ -143,6 +143,13 @@ define([
}); });
EditorApplication.getBody = sinon.stub(); EditorApplication.getBody = sinon.stub();
EditorApplication.getNewsletter = function () {
return {
get: function () {
return 'standard';
}
};
};
module = SaveInjector({ module = SaveInjector({
mailpoet: { mailpoet: {
Ajax: { Ajax: {