Rename subject and preheader, fix tests

This commit is contained in:
Tautvidas Sipavičius
2015-09-23 14:24:24 +03:00
parent fd7312fbf9
commit 17564d85fe
5 changed files with 13 additions and 13 deletions

View File

@ -62,12 +62,12 @@ define([
App.toJSON = Module.toJSON; App.toJSON = Module.toJSON;
App.getNewsletter = Module.getNewsletter; App.getNewsletter = Module.getNewsletter;
Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['data', 'styles'])); Module.newsletter = new Module.NewsletterModel(_.omit(_.clone(options.newsletter), ['content', 'globalStyles']));
}); });
App.on('start', function(options) { App.on('start', function(options) {
// TODO: Other newsletter information will be needed as well. // TODO: Other newsletter information will be needed as well.
App._contentContainer = new (this.getBlockTypeModel('container'))(options.newsletter.data, {parse: true}); App._contentContainer = new (this.getBlockTypeModel('container'))(options.newsletter.content, {parse: true});
App._contentContainerView = new (this.getBlockTypeView('container'))({ App._contentContainerView = new (this.getBlockTypeView('container'))({
model: App._contentContainer, model: App._contentContainer,
renderOptions: { depth: 0 }, renderOptions: { depth: 0 },

View File

@ -19,8 +19,8 @@ define([
}, },
events: function() { events: function() {
return { return {
'keyup .mailpoet_input_title': _.partial(this.changeField, "newsletter_subject"), 'keyup .mailpoet_input_title': _.partial(this.changeField, "subject"),
'keyup .mailpoet_input_preheader': _.partial(this.changeField, "newsletter_preheader"), 'keyup .mailpoet_input_preheader': _.partial(this.changeField, "preheader"),
}; };
}, },
changeField: function(field, event) { changeField: function(field, event) {

View File

@ -50,13 +50,13 @@ define([
}); });
describe('transformation to json', function() { describe('transformation to json', function() {
it('includes data, styles and initial newsletter fields', function() { it('includes content, globalStyles and initial newsletter fields', function() {
var dataField = { var dataField = {
containerModelField: 'containerModelValue', containerModelField: 'containerModelValue',
}, stylesField = { }, stylesField = {
globalStylesField: 'globalStylesValue', globalStylesField: 'globalStylesValue',
}, newsletterFields = { }, newsletterFields = {
newsletter_subject: 'test newsletter subject', subject: 'test newsletter subject',
}; };
EditorApplication._contentContainer = { EditorApplication._contentContainer = {
toJSON: function() { toJSON: function() {

View File

@ -8,7 +8,7 @@ define([
var view; var view;
beforeEach(function() { beforeEach(function() {
var model = new Backbone.SuperModel({ var model = new Backbone.SuperModel({
newsletter_subject: 'a test subject', subject: 'a test subject',
}); });
view = new (HeadingComponent.HeadingView)({ view = new (HeadingComponent.HeadingView)({
model: model, model: model,
@ -23,8 +23,8 @@ define([
var view, model; var view, model;
beforeEach(function() { beforeEach(function() {
model = new Backbone.SuperModel({ model = new Backbone.SuperModel({
newsletter_subject: 'a test subject', subject: 'a test subject',
newsletter_preheader: 'a test preheader', preheader: 'a test preheader',
}); });
view = new (HeadingComponent.HeadingView)({ view = new (HeadingComponent.HeadingView)({
model: model, model: model,
@ -34,12 +34,12 @@ define([
it('changes the model when subject field is changed', function() { it('changes the model when subject field is changed', function() {
view.$('.mailpoet_input_title').val('a new testing subject').keyup(); view.$('.mailpoet_input_title').val('a new testing subject').keyup();
expect(model.get('newsletter_subject')).to.equal('a new testing subject'); expect(model.get('subject')).to.equal('a new testing subject');
}); });
it('changes the model when preheader field is changed', function() { it('changes the model when preheader field is changed', function() {
view.$('.mailpoet_input_preheader').val('a new testing preheader').keyup(); view.$('.mailpoet_input_preheader').val('a new testing preheader').keyup();
expect(model.get('newsletter_preheader')).to.equal('a new testing preheader'); expect(model.get('preheader')).to.equal('a new testing preheader');
}); });
}); });
}); });

View File

@ -1,6 +1,6 @@
<div class="mailpoet_form_field mailpoet_heading_form_field"> <div class="mailpoet_form_field mailpoet_heading_form_field">
<input type="text" class="mailpoet_input mailpoet_input_title" value="{{ model.newsletter_subject }}" placeholder="<%= __('Click to change the subject!') %>" /> <input type="text" class="mailpoet_input mailpoet_input_title" value="{{ model.subject }}" placeholder="<%= __('Click to change the subject!') %>" />
</div> </div>
<div class="mailpoet_form_field mailpoet_heading_form_field"> <div class="mailpoet_form_field mailpoet_heading_form_field">
<input type="text" class="mailpoet_input mailpoet_input_preheader" value="" placeholder="<%= __('Write your preheader here...') %>" /> <input type="text" class="mailpoet_input mailpoet_input_preheader" value="{{ model.preheader }}" placeholder="<%= __('Write your preheader here...') %>" />
</div> </div>