Add ES6 support to more files

This commit is contained in:
Robin Ward
2015-08-10 17:11:27 -04:00
parent 766903c430
commit e2e3e7c0e0
78 changed files with 419 additions and 387 deletions
+3 -1
View File
@@ -1,3 +1,5 @@
import Quote from 'discourse/lib/quote';
module("Discourse.BBCode");
var format = function(input, expected, text) {
@@ -90,7 +92,7 @@ test("quotes", function() {
});
var formatQuote = function(val, expected, text) {
equal(Discourse.Quote.build(post, val), expected, text);
equal(Quote.build(post, val), expected, text);
};
formatQuote(undefined, "", "empty string for undefined content");
@@ -1,5 +1,6 @@
module("lib:category-link");
import parseHTML from 'helpers/parse-html';
import { categoryBadgeHTML } from "discourse/helpers/category-link";
test("categoryBadge without a category", function() {
+10 -9
View File
@@ -1,3 +1,4 @@
import DiscourseURL from "discourse/lib/url";
import ClickTrack from "discourse/lib/click-track";
var windowOpen,
@@ -9,7 +10,7 @@ module("lib:click-track", {
// Prevent any of these tests from navigating away
win = {focus: function() { } };
redirectTo = sandbox.stub(Discourse.URL, "redirectTo");
redirectTo = sandbox.stub(DiscourseURL, "redirectTo");
sandbox.stub(Discourse, "ajax");
windowOpen = sandbox.stub(window, "open").returns(win);
sandbox.stub(win, "focus");
@@ -51,7 +52,7 @@ test("it calls preventDefault when clicking on an a", function() {
sandbox.stub(clickEvent, "preventDefault");
track(clickEvent);
ok(clickEvent.preventDefault.calledOnce);
ok(Discourse.URL.redirectTo.calledOnce);
ok(DiscourseURL.redirectTo.calledOnce);
});
test("does not track clicks on back buttons", function() {
@@ -70,7 +71,7 @@ test("removes the href and put it as a data attribute", function() {
equal($link.data('href'), 'http://www.google.com');
blank($link.attr('href'));
ok($link.data('auto-route'));
ok(Discourse.URL.redirectTo.calledOnce);
ok(DiscourseURL.redirectTo.calledOnce);
});
asyncTest("restores the href after a while", function() {
@@ -159,20 +160,20 @@ testOpenInANewTab("it opens in a new tab on middle click", function(clickEvent)
});
test("tracks via AJAX if we're on the same site", function() {
sandbox.stub(Discourse.URL, "routeTo");
sandbox.stub(Discourse.URL, "origin").returns("http://discuss.domain.com");
sandbox.stub(DiscourseURL, "routeTo");
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
ok(!track(generateClickEventOn('#same-site')));
ok(Discourse.ajax.calledOnce);
ok(Discourse.URL.routeTo.calledOnce);
ok(DiscourseURL.routeTo.calledOnce);
});
test("does not track via AJAX for attachments", function() {
sandbox.stub(Discourse.URL, "routeTo");
sandbox.stub(Discourse.URL, "origin").returns("http://discuss.domain.com");
sandbox.stub(DiscourseURL, "routeTo");
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
ok(!track(generateClickEventOn('.attachment')));
ok(Discourse.URL.redirectTo.calledOnce);
ok(DiscourseURL.redirectTo.calledOnce);
});
test("tracks custom urls when opening in another window", function() {
-14
View File
@@ -1,14 +0,0 @@
module("Discourse.HTML");
var html = Discourse.HTML;
test("customHTML", function() {
blank(html.getCustomHTML('evil'), "there is no custom HTML for a key by default");
html.setCustomHTML('evil', 'trout');
equal(html.getCustomHTML('evil'), 'trout', 'it retrieves the custom html');
PreloadStore.store('customHTML', {cookie: 'monster'});
equal(html.getCustomHTML('cookie'), 'monster', 'it returns HTML fragments from the PreloadStore');
});
+11 -9
View File
@@ -1,16 +1,18 @@
module("Discourse.URL");
import DiscourseURL from 'discourse/lib/url';
module("lib:url");
test("isInternal with a HTTP url", function() {
sandbox.stub(Discourse.URL, "origin").returns("http://eviltrout.com");
sandbox.stub(DiscourseURL, "origin").returns("http://eviltrout.com");
not(Discourse.URL.isInternal(null), "a blank URL is not internal");
ok(Discourse.URL.isInternal("/test"), "relative URLs are internal");
ok(Discourse.URL.isInternal("http://eviltrout.com/tophat"), "a url on the same host is internal");
ok(Discourse.URL.isInternal("https://eviltrout.com/moustache"), "a url on a HTTPS of the same host is internal");
not(Discourse.URL.isInternal("http://twitter.com"), "a different host is not internal");
not(DiscourseURL.isInternal(null), "a blank URL is not internal");
ok(DiscourseURL.isInternal("/test"), "relative URLs are internal");
ok(DiscourseURL.isInternal("http://eviltrout.com/tophat"), "a url on the same host is internal");
ok(DiscourseURL.isInternal("https://eviltrout.com/moustache"), "a url on a HTTPS of the same host is internal");
not(DiscourseURL.isInternal("http://twitter.com"), "a different host is not internal");
});
test("isInternal with a HTTPS url", function() {
sandbox.stub(Discourse.URL, "origin").returns("https://eviltrout.com");
ok(Discourse.URL.isInternal("http://eviltrout.com/monocle"), "HTTPS urls match HTTP urls");
sandbox.stub(DiscourseURL, "origin").returns("https://eviltrout.com");
ok(DiscourseURL.isInternal("http://eviltrout.com/monocle"), "HTTPS urls match HTTP urls");
});