Skip to content

Commit 345960e

Browse files
committed
Merge pull request discourse#1634 from velesin/click_track_tests_fixture_helper
refactors click track tests to use fixture helper
2 parents b73ae0d + e31559b commit 345960e

1 file changed

Lines changed: 6 additions & 6 deletions

File tree

test/javascripts/lib/click_track_test.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ module("Discourse.ClickTrack", {
88
this.windowOpen = sinon.stub(window, "open").returns(this.win);
99
sinon.stub(this.win, "focus");
1010

11-
$('#qunit-fixture').html([
11+
fixture().html([
1212
'<div id="topic" id="1337">',
1313
' <article data-post-id="42" data-user-id="3141">',
1414
' <a href="http://www.google.com">google.com</a>',
@@ -37,7 +37,7 @@ var track = Discourse.ClickTrack.trackClick;
3737

3838
// test
3939
var generateClickEventOn = function(selector) {
40-
return $.Event("click", { currentTarget: $("#qunit-fixture " + selector)[0] });
40+
return $.Event("click", { currentTarget: fixture(selector)[0] });
4141
};
4242

4343
test("does not track clicks on lightboxes", function() {
@@ -66,7 +66,7 @@ test("does not track clicks on quote buttons", function() {
6666
test("removes the href and put it as a data attribute", function() {
6767
track(generateClickEventOn('a'));
6868

69-
var $link = $('#qunit-fixture a').first();
69+
var $link = fixture('a').first();
7070
ok($link.hasClass('no-href'));
7171
equal($link.data('href'), 'http://www.google.com');
7272
blank($link.attr('href'));
@@ -77,7 +77,7 @@ test("removes the href and put it as a data attribute", function() {
7777

7878
var badgeClickCount = function(id, expected) {
7979
track(generateClickEventOn('#' + id));
80-
var $badge = $('span.badge', $('#qunit-fixture #' + id).first());
80+
var $badge = $('span.badge', fixture('#' + id).first());
8181
equal(parseInt($badge.html(), 10), expected);
8282
};
8383

@@ -105,13 +105,13 @@ var trackRightClick = function() {
105105

106106
test("right clicks change the href", function() {
107107
ok(trackRightClick());
108-
equal($('#qunit-fixture a').first().prop('href'), "http://www.google.com/");
108+
equal(fixture('a').first().prop('href'), "http://www.google.com/");
109109
});
110110

111111
test("right clicks are tracked", function() {
112112
Discourse.SiteSettings.track_external_right_clicks = true;
113113
trackRightClick();
114-
equal($('#qunit-fixture a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42");
114+
equal(fixture('a').first().attr('href'), "/clicks/track?url=http%3A%2F%2Fwww.google.com&post_id=42");
115115
});
116116

117117

0 commit comments

Comments
 (0)