Component tests for like button

This commit is contained in:
Robin Ward
2015-07-14 14:23:56 -04:00
parent 7a58d64f37
commit fcfcda099f
4 changed files with 715 additions and 10 deletions
@@ -2,13 +2,51 @@ import componentTest from 'helpers/component-test';
moduleForComponent('post-menu', {integration: true});
componentTest('render buttons', {
template: "{{post-menu post=post}}",
setup(store) {
const topic = store.createRecord('topic', {id: 123});
this.set('post', store.createRecord('post', {id: 1, post_number: 1, topic}));
},
function setup(store) {
const topic = store.createRecord('topic', {id: 123});
const post = store.createRecord('post', {
id: 1,
post_number: 1,
topic,
like_count: 3,
actions_summary: [
{id: 2, count: 3, hidden: false, can_act: true}
]
});
this.on('toggleLike', function() {
post.toggleProperty('actionByName.like.acted');
});
this.set('post', post);
}
componentTest('basic render', {
template: '{{post-menu post=post}}',
setup,
test(assert) {
assert.ok(this.$('.post-menu-area').length, 'it renders a post menu');
assert.ok(!!this.$('.post-menu-area').length, 'it renders a post menu');
assert.ok(!!this.$('.actions button[data-share-url]').length, 'it renders a share button');
}
});
componentTest('liking', {
template: '{{post-menu post=post toggleLike="toggleLike"}}',
setup,
test(assert) {
assert.ok(!!this.$('.actions button.like').length);
assert.ok(!!this.$('.actions button.like-count').length);
click('.actions button.like');
andThen(() => {
assert.ok(!this.$('.actions button.like').length);
assert.ok(!!this.$('.actions button.has-like').length);
});
click('.actions button.has-like');
andThen(() => {
assert.ok(!!this.$('.actions button.like').length);
assert.ok(!this.$('.actions button.has-like').length);
});
}
});