From e31559b05fe0a2af63c8f2ce015b15c5cdd9e0d4 Mon Sep 17 00:00:00 2001 From: Wojciech Zawistowski Date: Fri, 8 Nov 2013 20:30:20 +0100 Subject: [PATCH] refactors click track tests to use fixture helper --- test/javascripts/lib/click_track_test.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/javascripts/lib/click_track_test.js b/test/javascripts/lib/click_track_test.js index 1a01a9bd4..60e5b87fb 100644 --- a/test/javascripts/lib/click_track_test.js +++ b/test/javascripts/lib/click_track_test.js @@ -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([ '
', '
', ' google.com', @@ -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"); });