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

View File

@ -15,10 +15,12 @@ export const Button = function(action, label, icon, opts) {
};
function animateHeart($elem, start, end, complete) {
if (Ember.testing) { return Ember.run(this, complete); }
$elem.stop()
.css('textIndent', start)
.animate({ textIndent: end }, {
complete: complete,
complete,
step(now) {
$(this).css('transform','scale('+now+')');
},

View File

@ -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);
});
}
});

File diff suppressed because one or more lines are too long

View File

@ -1,3 +1,97 @@
/*jshint maxlen:10000000 */
Discourse.SiteSettingsOriginal = {"title":"Discourse Meta","logo_url":"/assets/logo.png","logo_small_url":"/assets/logo-single.png","mobile_logo_url":"","favicon_url":"//meta.discourse.org/uploads/default/2499/79d53726406d87af.ico","allow_user_locale":false,"suggested_topics":7,"track_external_right_clicks":false,"ga_universal_tracking_code":"","ga_universal_domain_name":"auto","ga_tracking_code":"UA-33736483-2","ga_domain_name":"","top_menu":"latest|new|unread|categories|top","post_menu":"like|share|flag|edit|bookmark|delete|admin|reply","post_menu_hidden_items":"edit|delete|admin","share_links":"twitter|facebook|google+|email","category_colors":"BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890","enable_mobile_theme":true,"relative_date_duration":14,"category_featured_topics":4,"fixed_category_positions":false,"show_subcategory_list":false,"enable_badges":true,"invite_only":false,"login_required":false,"must_approve_users":false,"enable_local_logins":true,"allow_new_registrations":true,"enable_google_logins":true,"enable_google_oauth2_logins":false,"enable_yahoo_logins":true,"enable_twitter_logins":true,"enable_facebook_logins":true,"enable_github_logins":true,"enable_sso":false,"min_username_length":3,"max_username_length":20,"min_password_length":8,"enable_names":true,"invites_shown":30,"delete_user_max_post_age":60,"delete_all_posts_max":15,"min_post_length":20,"min_private_message_post_length":10,"max_post_length":32000,"min_topic_title_length":15,"max_topic_title_length":255,"min_private_message_title_length":2,"allow_uncategorized_topics":true,"min_title_similar_length":10,"min_body_similar_length":15,"edit_history_visible_to_public":true,"delete_removed_posts_after":24,"traditional_markdown_linebreaks":false,"suppress_reply_directly_below":true,"suppress_reply_directly_above":true,"newuser_max_images":0,"newuser_max_attachments":0,"display_name_on_posts":true,"short_progress_text_threshold":10000,"default_code_lang":"lang-auto","autohighlight_all_code":false,"email_in":false,"max_image_size_kb":3072,"max_attachment_size_kb":1024,"authorized_extensions":".jpg|.jpeg|.png|.gif|.svg|.txt|.ico|.yml","max_image_width":690,"max_image_height":500,"allow_profile_backgrounds":true,"allow_uploaded_avatars":true,"allow_animated_avatars":false,"tl1_requires_read_posts":30,"enable_long_polling":true,"polling_interval":3000,"anon_polling_interval":30000,"flush_timings_secs":5,"tos_url":"","privacy_policy_url":"","tos_accept_required":false,"faq_url":"","allow_restore":false,"maximum_backups":7,"version_checks":true,"suppress_uncategorized_badge":true,"min_search_term_length":3,"topic_views_heat_low":1000,"topic_views_heat_medium":2000,"topic_views_heat_high":5000,"global_notice":"","show_create_topics_notice":true,"available_locales":"cs|da|de|en|es|fr|he|id|it|ja|ko|nb_NO|nl|pl_PL|pt|pt_BR|ru|sv|uk|zh_CN|zh_TW","highlighted_languages":"apache|bash|cs|cpp|css|coffeescript|diff|xml|http|ini|json|java|javascript|makefile|markdown|nginx|objectivec|ruby|perl|php|python|sql|handlebars","enable_emoji":true};
Discourse.SiteSettingsOriginal = {
"title":"Discourse Meta",
"logo_url":"/assets/logo.png",
"logo_small_url":"/assets/logo-single.png",
"mobile_logo_url":"",
"favicon_url":"//meta.discourse.org/uploads/default/2499/79d53726406d87af.ico",
"allow_user_locale":false,
"suggested_topics":7,
"track_external_right_clicks":false,
"ga_universal_tracking_code":"",
"ga_universal_domain_name":"auto",
"ga_tracking_code":"UA-33736483-2",
"ga_domain_name":"",
"top_menu":"latest|new|unread|categories|top",
"post_menu":"like-count|like|share|flag|edit|bookmark|delete|admin|reply",
"post_menu_hidden_items":"edit|delete|admin",
"share_links":"twitter|facebook|google+|email",
"category_colors":"BF1E2E|F1592A|F7941D|9EB83B|3AB54A|12A89D|25AAE2|0E76BD|652D90|92278F|ED207B|8C6238|231F20|808281|B3B5B4|283890",
"enable_mobile_theme":true,
"relative_date_duration":14,
"category_featured_topics":4,
"fixed_category_positions":false,
"show_subcategory_list":false,
"enable_badges":true,
"invite_only":false,
"login_required":false,
"must_approve_users":false,
"enable_local_logins":true,
"allow_new_registrations":true,
"enable_google_logins":true,
"enable_google_oauth2_logins":false,
"enable_yahoo_logins":true,
"enable_twitter_logins":true,
"enable_facebook_logins":true,
"enable_github_logins":true,
"enable_sso":false,
"min_username_length":3,
"max_username_length":20,
"min_password_length":8,
"enable_names":true,
"invites_shown":30,
"delete_user_max_post_age":60,
"delete_all_posts_max":15,
"min_post_length":20,
"min_private_message_post_length":10,
"max_post_length":32000,
"min_topic_title_length":15,
"max_topic_title_length":255,
"min_private_message_title_length":2,
"allow_uncategorized_topics":true,
"min_title_similar_length":10,
"min_body_similar_length":15,
"edit_history_visible_to_public":true,
"delete_removed_posts_after":24,
"traditional_markdown_linebreaks":false,
"suppress_reply_directly_below":true,
"suppress_reply_directly_above":true,
"newuser_max_images":0,
"newuser_max_attachments":0,
"display_name_on_posts":true,
"short_progress_text_threshold":10000,
"default_code_lang":"lang-auto",
"autohighlight_all_code":false,
"email_in":false,
"max_image_size_kb":3072,
"max_attachment_size_kb":1024,
"authorized_extensions":".jpg|.jpeg|.png|.gif|.svg|.txt|.ico|.yml",
"max_image_width":690,
"max_image_height":500,
"allow_profile_backgrounds":true,
"allow_uploaded_avatars":true,
"allow_animated_avatars":false,
"tl1_requires_read_posts":30,
"enable_long_polling":true,
"polling_interval":3000,
"anon_polling_interval":30000,
"flush_timings_secs":5,
"tos_url":"",
"privacy_policy_url":"",
"tos_accept_required":false,
"faq_url":"",
"allow_restore":false,
"maximum_backups":7,
"version_checks":true,
"suppress_uncategorized_badge":true,
"min_search_term_length":3,
"topic_views_heat_low":1000,
"topic_views_heat_medium":2000,
"topic_views_heat_high":5000,
"global_notice":"",
"show_create_topics_notice":true,
"available_locales":"cs|da|de|en|es|fr|he|id|it|ja|ko|nb_NO|nl|pl_PL|pt|pt_BR|ru|sv|uk|zh_CN|zh_TW",
"highlighted_languages":"apache|bash|cs|cpp|css|coffeescript|diff|xml|http|ini|json|java|javascript|makefile|markdown|nginx|objectivec|ruby|perl|php|python|sql|handlebars",
"enable_emoji":true
};
Discourse.SiteSettings = jQuery.extend(true, {}, Discourse.SiteSettingsOriginal);