mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:30:26 -06:00
Merge pull request #1634 from velesin/click_track_tests_fixture_helper
refactors click track tests to use fixture helper
This commit is contained in:
commit
345960e194
@ -8,7 +8,7 @@ module("Discourse.ClickTrack", {
|
||||
this.windowOpen = sinon.stub(window, "open").returns(this.win);
|
||||
sinon.stub(this.win, "focus");
|
||||
|
||||
$('#qunit-fixture').html([
|
||||
fixture().html([
|
||||
'<div id="topic" id="1337">',
|
||||
' <article data-post-id="42" data-user-id="3141">',
|
||||
' <a href="http://www.google.com">google.com</a>',
|
||||
@ -37,7 +37,7 @@ var track = Discourse.ClickTrack.trackClick;
|
||||
|
||||
// test
|
||||
var generateClickEventOn = function(selector) {
|
||||
return $.Event("click", { currentTarget: $("#qunit-fixture " + selector)[0] });
|
||||
return $.Event("click", { currentTarget: fixture(selector)[0] });
|
||||
};
|
||||
|
||||
test("does not track clicks on lightboxes", function() {
|
||||
@ -66,7 +66,7 @@ test("does not track clicks on quote buttons", function() {
|
||||
test("removes the href and put it as a data attribute", function() {
|
||||
track(generateClickEventOn('a'));
|
||||
|
||||
var $link = $('#qunit-fixture a').first();
|
||||
var $link = fixture('a').first();
|
||||
ok($link.hasClass('no-href'));
|
||||
equal($link.data('href'), 'http://www.google.com');
|
||||
blank($link.attr('href'));
|
||||
@ -77,7 +77,7 @@ test("removes the href and put it as a data attribute", function() {
|
||||
|
||||
var badgeClickCount = function(id, expected) {
|
||||
track(generateClickEventOn('#' + id));
|
||||
var $badge = $('span.badge', $('#qunit-fixture #' + id).first());
|
||||
var $badge = $('span.badge', fixture('#' + id).first());
|
||||
equal(parseInt($badge.html(), 10), expected);
|
||||
};
|
||||
|
||||
@ -105,13 +105,13 @@ var trackRightClick = function() {
|
||||
|
||||
test("right clicks change the href", function() {
|
||||
ok(trackRightClick());
|
||||
equal($('#qunit-fixture a').first().prop('href'), "http://www.google.com/");
|
||||
equal(fixture('a').first().prop('href'), "http://www.google.com/");
|
||||
});
|
||||
|
||||
test("right clicks are tracked", function() {
|
||||
Discourse.SiteSettings.track_external_right_clicks = true;
|
||||
trackRightClick();
|
||||
equal($('#qunit-fixture a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42");
|
||||
equal(fixture('a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42");
|
||||
});
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user