Fix Posts block tests
This commit is contained in:
@@ -107,22 +107,20 @@ define([
|
|||||||
},
|
},
|
||||||
_refreshTransformedPosts: function() {
|
_refreshTransformedPosts: function() {
|
||||||
var that = this,
|
var that = this,
|
||||||
data = this.toJSON(),
|
data = this.toJSON();
|
||||||
index = this.collection.indexOf(this),
|
|
||||||
collection = this.get('_transformedPosts');
|
|
||||||
|
|
||||||
data.posts = this.get('_selectedPosts').pluck('ID');
|
data.posts = this.get('_selectedPosts').pluck('ID');
|
||||||
|
|
||||||
if (data.posts.length === 0) {
|
if (data.posts.length === 0) {
|
||||||
that.get('_transformedPosts').get('blocks').reset();
|
this.get('_transformedPosts.blocks').reset();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
WordpressComponent.getTransformedPosts(data).done(function(posts) {
|
WordpressComponent.getTransformedPosts(data).done(function(posts) {
|
||||||
console.log('Available posts fetched', arguments);
|
console.log('Transformed posts fetched', arguments);
|
||||||
that.get('_transformedPosts').get('blocks').reset(posts, {parse: true});
|
that.get('_transformedPosts').get('blocks').reset(posts, {parse: true});
|
||||||
}).fail(function() {
|
}).fail(function() {
|
||||||
console.log('Posts fetchPosts error', arguments);
|
console.log('Posts _refreshTransformedPosts error', arguments);
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
_insertSelectedPosts: function() {
|
_insertSelectedPosts: function() {
|
||||||
|
@@ -1,7 +1,7 @@
|
|||||||
define([
|
define([
|
||||||
'newsletter_editor/App',
|
'newsletter_editor/App',
|
||||||
'newsletter_editor/components/wordpress',
|
'newsletter_editor/components/wordpress',
|
||||||
'newsletter_editor/blocks/posts',
|
'newsletter_editor/blocks/posts'
|
||||||
], function(EditorApplication, WordpressComponent, PostsBlock) {
|
], function(EditorApplication, WordpressComponent, PostsBlock) {
|
||||||
|
|
||||||
describe('Posts', function () {
|
describe('Posts', function () {
|
||||||
@@ -373,12 +373,7 @@ define([
|
|||||||
});
|
});
|
||||||
|
|
||||||
describe('when "title as list" is selected', function() {
|
describe('when "title as list" is selected', function() {
|
||||||
var model, view;
|
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
model = new (PostsBlock.PostsBlockModel)();
|
|
||||||
model.request = sinon.stub().returns({$el: {}});
|
|
||||||
view = new (PostsBlock.PostsBlockSettingsView)({model: model});
|
|
||||||
view.render();
|
|
||||||
view.$('.mailpoet_posts_display_type').val('titleOnly').change();
|
view.$('.mailpoet_posts_display_type').val('titleOnly').change();
|
||||||
view.$('.mailpoet_posts_title_format').val('ul').change();
|
view.$('.mailpoet_posts_title_format').val('ul').change();
|
||||||
});
|
});
|
||||||
|
Reference in New Issue
Block a user