Fix javascript tests

[MAILPOET-2281]
This commit is contained in:
Amine Ben hammou
2019-09-25 01:36:38 +01:00
committed by Jack Kitterhing
parent b17ade80c2
commit 61cd5e1cc2
2 changed files with 35 additions and 5 deletions

View File

@@ -10,6 +10,9 @@ describe('Heading', function () {
var model = new Backbone.SuperModel({ var model = new Backbone.SuperModel({
subject: 'a test subject', subject: 'a test subject',
}); });
model.isWoocommerceTransactional = function () {
return false;
};
view = new (HeadingComponent.HeadingView)({ view = new (HeadingComponent.HeadingView)({
model: model, model: model,
}); });
@@ -26,6 +29,9 @@ describe('Heading', function () {
subject: 'a test subject', subject: 'a test subject',
preheader: 'a test preheader', preheader: 'a test preheader',
}); });
model.isWoocommerceTransactional = function () {
return false;
};
view = new (HeadingComponent.HeadingView)({ view = new (HeadingComponent.HeadingView)({
model: model, model: model,
}); });

View File

@@ -7,6 +7,7 @@ import SaveInjector from 'inject-loader!babel-loader?plugins[]=@babel/plugin-tra
const expect = global.expect; const expect = global.expect;
const sinon = global.sinon; const sinon = global.sinon;
const Backbone = global.Backbone;
var EditorApplication = App; var EditorApplication = App;
@@ -109,15 +110,25 @@ describe('Save', function () {
}); });
it('renders', function () { it('renders', function () {
var view = new (SaveComponent.SaveView)(); var view;
var model = new Backbone.SuperModel({});
model.isWoocommerceTransactional = function () {
return false;
};
view = new (SaveComponent.SaveView)({ model: model });
expect(view.render).to.not.throw(); expect(view.render).to.not.throw();
}); });
describe('validateNewsletter', function () { describe('validateNewsletter', function () {
var hideValidationErrorStub; var hideValidationErrorStub;
var view; var view;
var model;
beforeEach(function () { beforeEach(function () {
view = new (SaveComponent.SaveView)(); model = new Backbone.SuperModel({});
model.isWoocommerceTransactional = function () {
return false;
};
view = new (SaveComponent.SaveView)({ model: model });
hideValidationErrorStub = sinon.stub(view, 'hideValidationError'); hideValidationErrorStub = sinon.stub(view, 'hideValidationError');
}); });
@@ -152,9 +163,14 @@ describe('Save', function () {
describe('once rendered', function () { describe('once rendered', function () {
var view; var view;
var model;
beforeEach(function () { beforeEach(function () {
EditorApplication._contentContainer = { isValid: sinon.stub().returns(true) }; EditorApplication._contentContainer = { isValid: sinon.stub().returns(true) };
view = new (SaveComponent.SaveView)(); model = new Backbone.SuperModel({});
model.isWoocommerceTransactional = function () {
return false;
};
view = new (SaveComponent.SaveView)({ model: model });
view.render(); view.render();
}); });
@@ -213,7 +229,11 @@ describe('Save', function () {
}, },
}, },
}).default; }).default;
view = new (module.SaveView)(); model = new Backbone.SuperModel({});
model.isWoocommerceTransactional = function () {
return false;
};
view = new (module.SaveView)({ model: model });
view.render(); view.render();
view.$('.mailpoet_save_as_template_name').val('A sample template'); view.$('.mailpoet_save_as_template_name').val('A sample template');
@@ -235,7 +255,11 @@ describe('Save', function () {
global.stubChannel(EditorApplication, { global.stubChannel(EditorApplication, {
trigger: spy, trigger: spy,
}); });
view = new (module.SaveView)(); model = new Backbone.SuperModel({});
model.isWoocommerceTransactional = function () {
return false;
};
view = new (module.SaveView)({ model: model });
view.render(); view.render();
view.$('.mailpoet_save_next').click(); view.$('.mailpoet_save_next').click();