2015-07-14 13:56:59 -04:00
|
|
|
import componentTest from 'helpers/component-test';
|
|
|
|
|
|
|
|
moduleForComponent('post-menu', {integration: true});
|
|
|
|
|
2015-07-14 14:23:56 -04:00
|
|
|
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,
|
2015-07-14 13:56:59 -04:00
|
|
|
test(assert) {
|
2015-07-14 14:23:56 -04:00
|
|
|
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);
|
|
|
|
});
|
2015-07-14 13:56:59 -04:00
|
|
|
}
|
|
|
|
});
|