2015-07-15 01:56:59 +08:00
|
|
|
import componentTest from 'helpers/component-test';
|
|
|
|
|
|
|
|
moduleForComponent('post-menu', {integration: true});
|
|
|
|
|
2015-07-15 02:23:56 +08: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() {
|
2015-07-15 03:50:27 +08:00
|
|
|
post.toggleProperty('likeAction.acted');
|
2015-07-15 02:23:56 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
this.set('post', post);
|
|
|
|
}
|
|
|
|
|
|
|
|
componentTest('basic render', {
|
|
|
|
template: '{{post-menu post=post}}',
|
|
|
|
setup,
|
2015-07-15 01:56:59 +08:00
|
|
|
test(assert) {
|
2015-07-15 02:23:56 +08: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-15 01:56:59 +08:00
|
|
|
}
|
|
|
|
});
|