Fix Posts block tests

This commit is contained in:
Tautvidas Sipavičius
2015-11-17 16:31:57 +02:00
parent c9a42ebb76
commit 080ae88a04
2 changed files with 5 additions and 12 deletions

View File

@ -107,22 +107,20 @@ define([
},
_refreshTransformedPosts: function() {
var that = this,
data = this.toJSON(),
index = this.collection.indexOf(this),
collection = this.get('_transformedPosts');
data = this.toJSON();
data.posts = this.get('_selectedPosts').pluck('ID');
if (data.posts.length === 0) {
that.get('_transformedPosts').get('blocks').reset();
this.get('_transformedPosts.blocks').reset();
return;
}
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});
}).fail(function() {
console.log('Posts fetchPosts error', arguments);
console.log('Posts _refreshTransformedPosts error', arguments);
});
},
_insertSelectedPosts: function() {

View File

@ -1,7 +1,7 @@
define([
'newsletter_editor/App',
'newsletter_editor/components/wordpress',
'newsletter_editor/blocks/posts',
'newsletter_editor/blocks/posts'
], function(EditorApplication, WordpressComponent, PostsBlock) {
describe('Posts', function () {
@ -373,12 +373,7 @@ define([
});
describe('when "title as list" is selected', function() {
var model, view;
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_title_format').val('ul').change();
});