DEV: apply new coding standards (#10592)
This commit is contained in:
@@ -2,7 +2,7 @@ import { parseBBCodeTag } from "pretty-text/engines/discourse-markdown/bbcode-bl
|
||||
|
||||
QUnit.module("lib:pretty-text:bbcode");
|
||||
|
||||
QUnit.test("block with multiple quoted attributes", assert => {
|
||||
QUnit.test("block with multiple quoted attributes", (assert) => {
|
||||
const parsed = parseBBCodeTag('[test one="foo" two="bar bar"]', 0, 30);
|
||||
|
||||
assert.equal(parsed.tag, "test");
|
||||
|
||||
@@ -8,12 +8,12 @@ QUnit.module("lib:bookmark", {
|
||||
|
||||
afterEach() {
|
||||
sandbox.restore();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"formattedReminderTime works when the reminder time is tomorrow",
|
||||
assert => {
|
||||
(assert) => {
|
||||
let reminderAt = "2020-04-12 09:45:00";
|
||||
let reminderAtDate = moment
|
||||
.tz(reminderAt, "Australia/Brisbane")
|
||||
@@ -27,7 +27,7 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"formattedReminderTime works when the reminder time is today",
|
||||
assert => {
|
||||
(assert) => {
|
||||
let reminderAt = "2020-04-11 09:45:00";
|
||||
let reminderAtDate = moment
|
||||
.tz(reminderAt, "Australia/Brisbane")
|
||||
@@ -41,7 +41,7 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"formattedReminderTime works when the reminder time is in the future",
|
||||
assert => {
|
||||
(assert) => {
|
||||
let reminderAt = "2020-04-15 09:45:00";
|
||||
let reminderAtDate = moment
|
||||
.tz(reminderAt, "Australia/Brisbane")
|
||||
|
||||
@@ -2,8 +2,8 @@
|
||||
|
||||
QUnit.module("lib:breakString", {});
|
||||
|
||||
QUnit.test("breakString", assert => {
|
||||
var b = function(s, hint) {
|
||||
QUnit.test("breakString", (assert) => {
|
||||
var b = function (s, hint) {
|
||||
return new BreakString(s).break(hint);
|
||||
};
|
||||
|
||||
|
||||
@@ -6,18 +6,18 @@ discourseModule("lib:category-link");
|
||||
|
||||
import { categoryBadgeHTML } from "discourse/helpers/category-link";
|
||||
|
||||
QUnit.test("categoryBadge without a category", assert => {
|
||||
QUnit.test("categoryBadge without a category", (assert) => {
|
||||
assert.blank(categoryBadgeHTML(), "it returns no HTML");
|
||||
});
|
||||
|
||||
QUnit.test("Regular categoryBadge", assert => {
|
||||
QUnit.test("Regular categoryBadge", (assert) => {
|
||||
const store = createStore();
|
||||
const category = store.createRecord("category", {
|
||||
name: "hello",
|
||||
id: 123,
|
||||
description_text: "cool description",
|
||||
color: "ff0",
|
||||
text_color: "f00"
|
||||
text_color: "f00",
|
||||
});
|
||||
const tag = $.parseHTML(categoryBadgeHTML(category))[0];
|
||||
|
||||
@@ -37,7 +37,7 @@ QUnit.test("Regular categoryBadge", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("undefined color", assert => {
|
||||
QUnit.test("undefined color", (assert) => {
|
||||
const store = createStore();
|
||||
const noColor = store.createRecord("category", { name: "hello", id: 123 });
|
||||
const tag = $.parseHTML(categoryBadgeHTML(noColor))[0];
|
||||
@@ -48,7 +48,7 @@ QUnit.test("undefined color", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("topic count", assert => {
|
||||
QUnit.test("topic count", (assert) => {
|
||||
const store = createStore();
|
||||
const category = store.createRecord("category", { name: "hello", id: 123 });
|
||||
|
||||
@@ -63,11 +63,11 @@ QUnit.test("topic count", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("allowUncategorized", assert => {
|
||||
QUnit.test("allowUncategorized", (assert) => {
|
||||
const store = createStore();
|
||||
const uncategorized = store.createRecord("category", {
|
||||
name: "uncategorized",
|
||||
id: 345
|
||||
id: 345,
|
||||
});
|
||||
|
||||
sandbox
|
||||
@@ -85,7 +85,7 @@ QUnit.test("allowUncategorized", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("category names are wrapped in dir-spans", function(assert) {
|
||||
QUnit.test("category names are wrapped in dir-spans", function (assert) {
|
||||
this.siteSettings.support_mixed_text_direction = true;
|
||||
const store = createStore();
|
||||
const rtlCategory = store.createRecord("category", {
|
||||
@@ -93,12 +93,12 @@ QUnit.test("category names are wrapped in dir-spans", function(assert) {
|
||||
id: 123,
|
||||
description_text: "cool description",
|
||||
color: "ff0",
|
||||
text_color: "f00"
|
||||
text_color: "f00",
|
||||
});
|
||||
|
||||
const ltrCategory = store.createRecord("category", {
|
||||
name: "Programming in Ruby",
|
||||
id: 234
|
||||
id: 234,
|
||||
});
|
||||
|
||||
let tag = $.parseHTML(categoryBadgeHTML(rtlCategory))[0];
|
||||
@@ -110,24 +110,24 @@ QUnit.test("category names are wrapped in dir-spans", function(assert) {
|
||||
assert.equal(dirSpan.dir, "ltr");
|
||||
});
|
||||
|
||||
QUnit.test("recursive", function(assert) {
|
||||
QUnit.test("recursive", function (assert) {
|
||||
const store = createStore();
|
||||
|
||||
const foo = store.createRecord("category", {
|
||||
name: "foo",
|
||||
id: 1
|
||||
id: 1,
|
||||
});
|
||||
|
||||
const bar = store.createRecord("category", {
|
||||
name: "bar",
|
||||
id: 2,
|
||||
parent_category_id: foo.id
|
||||
parent_category_id: foo.id,
|
||||
});
|
||||
|
||||
const baz = store.createRecord("category", {
|
||||
name: "baz",
|
||||
id: 3,
|
||||
parent_category_id: bar.id
|
||||
parent_category_id: bar.id,
|
||||
});
|
||||
|
||||
this.siteSettings.max_category_nesting = 0;
|
||||
|
||||
@@ -8,7 +8,7 @@ QUnit.module("lib:click-track-edit-history", {
|
||||
beforeEach() {
|
||||
logIn();
|
||||
|
||||
let win = { focus: function() {} };
|
||||
let win = { focus: function () {} };
|
||||
sandbox.stub(window, "open").returns(win);
|
||||
sandbox.stub(win, "focus");
|
||||
|
||||
@@ -49,7 +49,7 @@ QUnit.module("lib:click-track-edit-history", {
|
||||
</div>
|
||||
</div>`
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
var track = ClickTrack.trackClick;
|
||||
@@ -58,12 +58,12 @@ function generateClickEventOn(selector) {
|
||||
return $.Event("click", { currentTarget: fixture(selector).first() });
|
||||
}
|
||||
|
||||
QUnit.skip("tracks internal URLs", async assert => {
|
||||
QUnit.skip("tracks internal URLs", async (assert) => {
|
||||
assert.expect(2);
|
||||
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
|
||||
|
||||
const done = assert.async();
|
||||
pretender.post("/clicks/track", request => {
|
||||
pretender.post("/clicks/track", (request) => {
|
||||
assert.equal(
|
||||
request.requestBody,
|
||||
"url=http%3A%2F%2Fdiscuss.domain.com&post_id=42&topic_id=1337"
|
||||
@@ -74,11 +74,11 @@ QUnit.skip("tracks internal URLs", async assert => {
|
||||
assert.notOk(track(generateClickEventOn("#same-site")));
|
||||
});
|
||||
|
||||
QUnit.skip("tracks external URLs", async assert => {
|
||||
QUnit.skip("tracks external URLs", async (assert) => {
|
||||
assert.expect(2);
|
||||
|
||||
const done = assert.async();
|
||||
pretender.post("/clicks/track", request => {
|
||||
pretender.post("/clicks/track", (request) => {
|
||||
assert.equal(
|
||||
request.requestBody,
|
||||
"url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
|
||||
@@ -91,12 +91,12 @@ QUnit.skip("tracks external URLs", async assert => {
|
||||
|
||||
QUnit.skip(
|
||||
"tracks external URLs when opening in another window",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
assert.expect(3);
|
||||
User.currentProp("external_links_in_new_tab", true);
|
||||
|
||||
const done = assert.async();
|
||||
pretender.post("/clicks/track", request => {
|
||||
pretender.post("/clicks/track", (request) => {
|
||||
assert.equal(
|
||||
request.requestBody,
|
||||
"url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
|
||||
|
||||
@@ -7,7 +7,7 @@ QUnit.module("lib:click-track-profile-page", {
|
||||
beforeEach() {
|
||||
logIn();
|
||||
|
||||
let win = { focus: function() {} };
|
||||
let win = { focus: function () {} };
|
||||
sandbox.stub(window, "open").returns(win);
|
||||
sandbox.stub(win, "focus");
|
||||
|
||||
@@ -42,7 +42,7 @@ QUnit.module("lib:click-track-profile-page", {
|
||||
<a class="hashtag" href="http://discuss.domain.com">#hashtag</a>
|
||||
</p>`
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
var track = ClickTrack.trackClick;
|
||||
@@ -51,12 +51,12 @@ function generateClickEventOn(selector) {
|
||||
return $.Event("click", { currentTarget: fixture(selector).first() });
|
||||
}
|
||||
|
||||
QUnit.skip("tracks internal URLs", async assert => {
|
||||
QUnit.skip("tracks internal URLs", async (assert) => {
|
||||
assert.expect(2);
|
||||
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
|
||||
|
||||
const done = assert.async();
|
||||
pretender.post("/clicks/track", request => {
|
||||
pretender.post("/clicks/track", (request) => {
|
||||
assert.equal(request.requestBody, "url=http%3A%2F%2Fdiscuss.domain.com");
|
||||
done();
|
||||
});
|
||||
@@ -64,11 +64,11 @@ QUnit.skip("tracks internal URLs", async assert => {
|
||||
assert.notOk(track(generateClickEventOn("#same-site")));
|
||||
});
|
||||
|
||||
QUnit.skip("tracks external URLs", async assert => {
|
||||
QUnit.skip("tracks external URLs", async (assert) => {
|
||||
assert.expect(2);
|
||||
|
||||
const done = assert.async();
|
||||
pretender.post("/clicks/track", request => {
|
||||
pretender.post("/clicks/track", (request) => {
|
||||
assert.equal(
|
||||
request.requestBody,
|
||||
"url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
|
||||
@@ -79,11 +79,11 @@ QUnit.skip("tracks external URLs", async assert => {
|
||||
assert.notOk(track(generateClickEventOn("a")));
|
||||
});
|
||||
|
||||
QUnit.skip("tracks external URLs in other posts", async assert => {
|
||||
QUnit.skip("tracks external URLs in other posts", async (assert) => {
|
||||
assert.expect(2);
|
||||
|
||||
const done = assert.async();
|
||||
pretender.post("/clicks/track", request => {
|
||||
pretender.post("/clicks/track", (request) => {
|
||||
assert.equal(
|
||||
request.requestBody,
|
||||
"url=http%3A%2F%2Fwww.google.com&post_id=24&topic_id=7331"
|
||||
|
||||
@@ -9,7 +9,7 @@ QUnit.module("lib:click-track", {
|
||||
beforeEach() {
|
||||
logIn();
|
||||
|
||||
let win = { focus: function() {} };
|
||||
let win = { focus: function () {} };
|
||||
sandbox.stub(window, "open").returns(win);
|
||||
sandbox.stub(win, "focus");
|
||||
|
||||
@@ -42,7 +42,7 @@ QUnit.module("lib:click-track", {
|
||||
</article>
|
||||
</div>`
|
||||
);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
var track = ClickTrack.trackClick;
|
||||
@@ -51,12 +51,12 @@ function generateClickEventOn(selector) {
|
||||
return $.Event("click", { currentTarget: fixture(selector).first() });
|
||||
}
|
||||
|
||||
QUnit.skip("tracks internal URLs", async assert => {
|
||||
QUnit.skip("tracks internal URLs", async (assert) => {
|
||||
assert.expect(2);
|
||||
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
|
||||
|
||||
const done = assert.async();
|
||||
pretender.post("/clicks/track", request => {
|
||||
pretender.post("/clicks/track", (request) => {
|
||||
assert.ok(
|
||||
request.requestBody,
|
||||
"url=http%3A%2F%2Fdiscuss.domain.com&post_id=42&topic_id=1337"
|
||||
@@ -67,11 +67,11 @@ QUnit.skip("tracks internal URLs", async assert => {
|
||||
assert.notOk(track(generateClickEventOn("#same-site")));
|
||||
});
|
||||
|
||||
QUnit.test("does not track elements with no href", async assert => {
|
||||
QUnit.test("does not track elements with no href", async (assert) => {
|
||||
assert.ok(track(generateClickEventOn(".a-without-href")));
|
||||
});
|
||||
|
||||
QUnit.test("does not track attachments", async assert => {
|
||||
QUnit.test("does not track attachments", async (assert) => {
|
||||
sandbox.stub(DiscourseURL, "origin").returns("http://discuss.domain.com");
|
||||
|
||||
pretender.post("/clicks/track", () => assert.ok(false));
|
||||
@@ -84,11 +84,11 @@ QUnit.test("does not track attachments", async assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.skip("tracks external URLs", async assert => {
|
||||
QUnit.skip("tracks external URLs", async (assert) => {
|
||||
assert.expect(2);
|
||||
|
||||
const done = assert.async();
|
||||
pretender.post("/clicks/track", request => {
|
||||
pretender.post("/clicks/track", (request) => {
|
||||
assert.ok(
|
||||
request.requestBody,
|
||||
"url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
|
||||
@@ -101,12 +101,12 @@ QUnit.skip("tracks external URLs", async assert => {
|
||||
|
||||
QUnit.skip(
|
||||
"tracks external URLs when opening in another window",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
assert.expect(3);
|
||||
User.currentProp("external_links_in_new_tab", true);
|
||||
|
||||
const done = assert.async();
|
||||
pretender.post("/clicks/track", request => {
|
||||
pretender.post("/clicks/track", (request) => {
|
||||
assert.ok(
|
||||
request.requestBody,
|
||||
"url=http%3A%2F%2Fwww.google.com&post_id=42&topic_id=1337"
|
||||
@@ -119,52 +119,55 @@ QUnit.skip(
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("does not track clicks on lightboxes", async assert => {
|
||||
QUnit.test("does not track clicks on lightboxes", async (assert) => {
|
||||
assert.notOk(track(generateClickEventOn(".lightbox")));
|
||||
});
|
||||
|
||||
QUnit.test("does not track clicks when forcibly disabled", async assert => {
|
||||
QUnit.test("does not track clicks when forcibly disabled", async (assert) => {
|
||||
assert.notOk(track(generateClickEventOn(".no-track-link")));
|
||||
});
|
||||
|
||||
QUnit.test("does not track clicks on back buttons", async assert => {
|
||||
QUnit.test("does not track clicks on back buttons", async (assert) => {
|
||||
assert.notOk(track(generateClickEventOn(".back")));
|
||||
});
|
||||
|
||||
QUnit.test("does not track right clicks inside quotes", async assert => {
|
||||
QUnit.test("does not track right clicks inside quotes", async (assert) => {
|
||||
const event = generateClickEventOn(".quote a:first-child");
|
||||
event.which = 3;
|
||||
assert.ok(track(event));
|
||||
});
|
||||
|
||||
QUnit.test("does not track clicks links in quotes", async assert => {
|
||||
QUnit.test("does not track clicks links in quotes", async (assert) => {
|
||||
User.currentProp("external_links_in_new_tab", true);
|
||||
assert.notOk(track(generateClickEventOn(".quote a:last-child")));
|
||||
assert.ok(window.open.calledWith("https://google.com/", "_blank"));
|
||||
});
|
||||
|
||||
QUnit.test("does not track clicks on category badges", async assert => {
|
||||
QUnit.test("does not track clicks on category badges", async (assert) => {
|
||||
assert.notOk(track(generateClickEventOn(".hashtag")));
|
||||
});
|
||||
|
||||
QUnit.test("does not track clicks on mailto", async assert => {
|
||||
QUnit.test("does not track clicks on mailto", async (assert) => {
|
||||
assert.ok(track(generateClickEventOn(".mailto")));
|
||||
});
|
||||
|
||||
QUnit.test("removes the href and put it as a data attribute", async assert => {
|
||||
User.currentProp("external_links_in_new_tab", true);
|
||||
QUnit.test(
|
||||
"removes the href and put it as a data attribute",
|
||||
async (assert) => {
|
||||
User.currentProp("external_links_in_new_tab", true);
|
||||
|
||||
assert.notOk(track(generateClickEventOn("a")));
|
||||
assert.notOk(track(generateClickEventOn("a")));
|
||||
|
||||
var $link = fixture("a").first();
|
||||
assert.ok($link.hasClass("no-href"));
|
||||
assert.equal($link.data("href"), "http://www.google.com/");
|
||||
assert.blank($link.attr("href"));
|
||||
assert.ok($link.data("auto-route"));
|
||||
assert.ok(window.open.calledWith("http://www.google.com/", "_blank"));
|
||||
});
|
||||
var $link = fixture("a").first();
|
||||
assert.ok($link.hasClass("no-href"));
|
||||
assert.equal($link.data("href"), "http://www.google.com/");
|
||||
assert.blank($link.attr("href"));
|
||||
assert.ok($link.data("auto-route"));
|
||||
assert.ok(window.open.calledWith("http://www.google.com/", "_blank"));
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("restores the href after a while", async assert => {
|
||||
QUnit.test("restores the href after a while", async (assert) => {
|
||||
assert.expect(2);
|
||||
|
||||
assert.notOk(track(generateClickEventOn("a")));
|
||||
@@ -184,30 +187,24 @@ function badgeClickCount(assert, id, expected) {
|
||||
assert.equal(parseInt($badge.html(), 10), expected);
|
||||
}
|
||||
|
||||
QUnit.test("does not update badge clicks on my own link", async assert => {
|
||||
sandbox
|
||||
.stub(User, "currentProp")
|
||||
.withArgs("id")
|
||||
.returns(314);
|
||||
QUnit.test("does not update badge clicks on my own link", async (assert) => {
|
||||
sandbox.stub(User, "currentProp").withArgs("id").returns(314);
|
||||
badgeClickCount(assert, "with-badge", 1);
|
||||
});
|
||||
|
||||
QUnit.test("does not update badge clicks in my own post", async assert => {
|
||||
sandbox
|
||||
.stub(User, "currentProp")
|
||||
.withArgs("id")
|
||||
.returns(3141);
|
||||
QUnit.test("does not update badge clicks in my own post", async (assert) => {
|
||||
sandbox.stub(User, "currentProp").withArgs("id").returns(3141);
|
||||
badgeClickCount(assert, "with-badge-but-not-mine", 1);
|
||||
});
|
||||
|
||||
QUnit.test("updates badge counts correctly", async assert => {
|
||||
QUnit.test("updates badge counts correctly", async (assert) => {
|
||||
badgeClickCount(assert, "inside-onebox", 1);
|
||||
badgeClickCount(assert, "inside-onebox-forced", 2);
|
||||
badgeClickCount(assert, "with-badge", 2);
|
||||
});
|
||||
|
||||
function testOpenInANewTab(description, clickEventModifier) {
|
||||
QUnit.test(description, async assert => {
|
||||
QUnit.test(description, async (assert) => {
|
||||
var clickEvent = generateClickEventOn("a");
|
||||
clickEventModifier(clickEvent);
|
||||
assert.ok(track(clickEvent));
|
||||
@@ -215,18 +212,18 @@ function testOpenInANewTab(description, clickEventModifier) {
|
||||
});
|
||||
}
|
||||
|
||||
testOpenInANewTab("it opens in a new tab when pressing shift", clickEvent => {
|
||||
testOpenInANewTab("it opens in a new tab when pressing shift", (clickEvent) => {
|
||||
clickEvent.shiftKey = true;
|
||||
});
|
||||
|
||||
testOpenInANewTab("it opens in a new tab when pressing meta", clickEvent => {
|
||||
testOpenInANewTab("it opens in a new tab when pressing meta", (clickEvent) => {
|
||||
clickEvent.metaKey = true;
|
||||
});
|
||||
|
||||
testOpenInANewTab("it opens in a new tab when pressing ctrl", clickEvent => {
|
||||
testOpenInANewTab("it opens in a new tab when pressing ctrl", (clickEvent) => {
|
||||
clickEvent.ctrlKey = true;
|
||||
});
|
||||
|
||||
testOpenInANewTab("it opens in a new tab on middle click", clickEvent => {
|
||||
testOpenInANewTab("it opens in a new tab on middle click", (clickEvent) => {
|
||||
clickEvent.button = 2;
|
||||
});
|
||||
|
||||
@@ -7,28 +7,28 @@ import {
|
||||
fmt,
|
||||
i18n,
|
||||
url,
|
||||
htmlSafe
|
||||
htmlSafe,
|
||||
} from "discourse/lib/computed";
|
||||
import { setPrefix } from "discourse-common/lib/get-url";
|
||||
import { discourseModule } from "helpers/qunit-helpers";
|
||||
|
||||
discourseModule("lib:computed", {
|
||||
beforeEach() {
|
||||
sandbox.stub(I18n, "t").callsFake(function(scope) {
|
||||
sandbox.stub(I18n, "t").callsFake(function (scope) {
|
||||
return "%@ translated: " + scope;
|
||||
});
|
||||
},
|
||||
|
||||
afterEach() {
|
||||
I18n.t.restore();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test("setting", function(assert) {
|
||||
QUnit.test("setting", function (assert) {
|
||||
let t = EmberObject.extend({
|
||||
siteSettings: this.siteSettings,
|
||||
vehicle: setting("vehicle"),
|
||||
missingProp: setting("madeUpThing")
|
||||
missingProp: setting("madeUpThing"),
|
||||
}).create();
|
||||
|
||||
this.siteSettings.vehicle = "airplane";
|
||||
@@ -43,12 +43,12 @@ QUnit.test("setting", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("propertyEqual", assert => {
|
||||
QUnit.test("propertyEqual", (assert) => {
|
||||
var t = EmberObject.extend({
|
||||
same: propertyEqual("cookies", "biscuits")
|
||||
same: propertyEqual("cookies", "biscuits"),
|
||||
}).create({
|
||||
cookies: 10,
|
||||
biscuits: 10
|
||||
biscuits: 10,
|
||||
});
|
||||
|
||||
assert.ok(t.get("same"), "it is true when the properties are the same");
|
||||
@@ -56,12 +56,12 @@ QUnit.test("propertyEqual", assert => {
|
||||
assert.ok(!t.get("same"), "it isn't true when one property is different");
|
||||
});
|
||||
|
||||
QUnit.test("propertyNotEqual", assert => {
|
||||
QUnit.test("propertyNotEqual", (assert) => {
|
||||
var t = EmberObject.extend({
|
||||
diff: propertyNotEqual("cookies", "biscuits")
|
||||
diff: propertyNotEqual("cookies", "biscuits"),
|
||||
}).create({
|
||||
cookies: 10,
|
||||
biscuits: 10
|
||||
biscuits: 10,
|
||||
});
|
||||
|
||||
assert.ok(!t.get("diff"), "it isn't true when the properties are the same");
|
||||
@@ -69,13 +69,13 @@ QUnit.test("propertyNotEqual", assert => {
|
||||
assert.ok(t.get("diff"), "it is true when one property is different");
|
||||
});
|
||||
|
||||
QUnit.test("fmt", assert => {
|
||||
QUnit.test("fmt", (assert) => {
|
||||
var t = EmberObject.extend({
|
||||
exclaimyUsername: fmt("username", "!!! %@ !!!"),
|
||||
multiple: fmt("username", "mood", "%@ is %@")
|
||||
multiple: fmt("username", "mood", "%@ is %@"),
|
||||
}).create({
|
||||
username: "eviltrout",
|
||||
mood: "happy"
|
||||
mood: "happy",
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
@@ -103,13 +103,13 @@ QUnit.test("fmt", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("i18n", assert => {
|
||||
QUnit.test("i18n", (assert) => {
|
||||
var t = EmberObject.extend({
|
||||
exclaimyUsername: i18n("username", "!!! %@ !!!"),
|
||||
multiple: i18n("username", "mood", "%@ is %@")
|
||||
multiple: i18n("username", "mood", "%@ is %@"),
|
||||
}).create({
|
||||
username: "eviltrout",
|
||||
mood: "happy"
|
||||
mood: "happy",
|
||||
});
|
||||
|
||||
assert.equal(
|
||||
@@ -137,11 +137,11 @@ QUnit.test("i18n", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("url", assert => {
|
||||
QUnit.test("url", (assert) => {
|
||||
var t, testClass;
|
||||
|
||||
testClass = EmberObject.extend({
|
||||
userUrl: url("username", "/u/%@")
|
||||
userUrl: url("username", "/u/%@"),
|
||||
});
|
||||
|
||||
t = testClass.create({ username: "eviltrout" });
|
||||
@@ -160,10 +160,10 @@ QUnit.test("url", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("htmlSafe", assert => {
|
||||
QUnit.test("htmlSafe", (assert) => {
|
||||
const cookies = "<p>cookies and <b>biscuits</b></p>";
|
||||
const t = EmberObject.extend({
|
||||
desc: htmlSafe("cookies")
|
||||
desc: htmlSafe("cookies"),
|
||||
}).create({ cookies });
|
||||
|
||||
assert.equal(t.get("desc").string, cookies);
|
||||
|
||||
@@ -7,25 +7,25 @@ discourseModule("lib:emoji-emojiStore", {
|
||||
},
|
||||
afterEach() {
|
||||
this.emojiStore.reset();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test("defaults", function(assert) {
|
||||
QUnit.test("defaults", function (assert) {
|
||||
assert.deepEqual(this.emojiStore.favorites, []);
|
||||
assert.equal(this.emojiStore.diversity, 1);
|
||||
});
|
||||
|
||||
QUnit.test("diversity", function(assert) {
|
||||
QUnit.test("diversity", function (assert) {
|
||||
this.emojiStore.diversity = 2;
|
||||
assert.equal(this.emojiStore.diversity, 2);
|
||||
});
|
||||
|
||||
QUnit.test("favorites", function(assert) {
|
||||
QUnit.test("favorites", function (assert) {
|
||||
this.emojiStore.favorites = ["smile"];
|
||||
assert.deepEqual(this.emojiStore.favorites, ["smile"]);
|
||||
});
|
||||
|
||||
QUnit.test("track", function(assert) {
|
||||
QUnit.test("track", function (assert) {
|
||||
this.emojiStore.track("woman:t4");
|
||||
assert.deepEqual(this.emojiStore.favorites, ["woman:t4"]);
|
||||
this.emojiStore.track("otter");
|
||||
|
||||
@@ -5,7 +5,7 @@ import { discourseModule } from "helpers/qunit-helpers";
|
||||
|
||||
discourseModule("lib:emoji");
|
||||
|
||||
QUnit.test("emojiUnescape", function(assert) {
|
||||
QUnit.test("emojiUnescape", function (assert) {
|
||||
const testUnescape = (input, expected, description, settings = {}) => {
|
||||
const originalSettings = {};
|
||||
for (const [key, value] of Object.entries(settings)) {
|
||||
@@ -103,7 +103,7 @@ QUnit.test("emojiUnescape", function(assert) {
|
||||
"Hello😊World",
|
||||
"keeps Unicode emoji when inline translation disabled",
|
||||
{
|
||||
enable_inline_emoji_translation: false
|
||||
enable_inline_emoji_translation: false,
|
||||
}
|
||||
);
|
||||
testUnescape(
|
||||
@@ -111,7 +111,7 @@ QUnit.test("emojiUnescape", function(assert) {
|
||||
`Hello<img src='/images/emoji/emoji_one/blush.png?v=${v}' title='blush' alt='blush' class='emoji'>World`,
|
||||
"emoji from Unicode emoji when inline translation enabled",
|
||||
{
|
||||
enable_inline_emoji_translation: true
|
||||
enable_inline_emoji_translation: true,
|
||||
}
|
||||
);
|
||||
testUnescape(
|
||||
@@ -119,7 +119,7 @@ QUnit.test("emojiUnescape", function(assert) {
|
||||
"hi:smile:",
|
||||
"no emojis when inline translation disabled",
|
||||
{
|
||||
enable_inline_emoji_translation: false
|
||||
enable_inline_emoji_translation: false,
|
||||
}
|
||||
);
|
||||
testUnescape(
|
||||
@@ -130,7 +130,7 @@ QUnit.test("emojiUnescape", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Emoji search", assert => {
|
||||
QUnit.test("Emoji search", (assert) => {
|
||||
// able to find an alias
|
||||
assert.equal(emojiSearch("+1").length, 1);
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ import {
|
||||
updateRelativeAge,
|
||||
number,
|
||||
longDate,
|
||||
durationTiny
|
||||
durationTiny,
|
||||
} from "discourse/lib/formatter";
|
||||
import { discourseModule } from "helpers/qunit-helpers";
|
||||
|
||||
@@ -15,14 +15,14 @@ discourseModule("lib:formatter", {
|
||||
|
||||
afterEach() {
|
||||
this.clock.restore();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
function formatMins(mins, opts = {}) {
|
||||
let dt = new Date(new Date() - mins * 60 * 1000);
|
||||
return relativeAge(dt, {
|
||||
format: opts.format || "tiny",
|
||||
leaveAgo: opts.leaveAgo
|
||||
leaveAgo: opts.leaveAgo,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -35,16 +35,12 @@ function formatDays(days, opts) {
|
||||
}
|
||||
|
||||
function shortDate(days) {
|
||||
return moment()
|
||||
.subtract(days, "days")
|
||||
.format("MMM D");
|
||||
return moment().subtract(days, "days").format("MMM D");
|
||||
}
|
||||
|
||||
function shortDateTester(format) {
|
||||
return function(days) {
|
||||
return moment()
|
||||
.subtract(days, "days")
|
||||
.format(format);
|
||||
return function (days) {
|
||||
return moment().subtract(days, "days").format(format);
|
||||
};
|
||||
}
|
||||
|
||||
@@ -52,7 +48,7 @@ function strip(html) {
|
||||
return $(html).text();
|
||||
}
|
||||
|
||||
QUnit.test("formating medium length dates", function(assert) {
|
||||
QUnit.test("formating medium length dates", function (assert) {
|
||||
let shortDateYear = shortDateTester("MMM D, 'YY");
|
||||
|
||||
assert.equal(
|
||||
@@ -123,7 +119,7 @@ QUnit.test("formating medium length dates", function(assert) {
|
||||
assert.equal(strip(formatDays(10, { format: "medium" })), shortDateYear(10));
|
||||
});
|
||||
|
||||
QUnit.test("formating tiny dates", function(assert) {
|
||||
QUnit.test("formating tiny dates", function (assert) {
|
||||
let shortDateYear = shortDateTester("MMM 'YY");
|
||||
|
||||
assert.equal(formatMins(0), "1m");
|
||||
@@ -186,10 +182,8 @@ QUnit.test("formating tiny dates", function(assert) {
|
||||
this.siteSettings.relative_date_duration = originalValue;
|
||||
});
|
||||
|
||||
QUnit.test("autoUpdatingRelativeAge", function(assert) {
|
||||
var d = moment()
|
||||
.subtract(1, "day")
|
||||
.toDate();
|
||||
QUnit.test("autoUpdatingRelativeAge", function (assert) {
|
||||
var d = moment().subtract(1, "day").toDate();
|
||||
|
||||
var $elem = $(autoUpdatingRelativeAge(d));
|
||||
assert.equal($elem.data("format"), "tiny");
|
||||
@@ -203,7 +197,7 @@ QUnit.test("autoUpdatingRelativeAge", function(assert) {
|
||||
autoUpdatingRelativeAge(d, {
|
||||
format: "medium",
|
||||
title: true,
|
||||
leaveAgo: true
|
||||
leaveAgo: true,
|
||||
})
|
||||
);
|
||||
assert.equal($elem.data("format"), "medium-with-ago");
|
||||
@@ -218,7 +212,7 @@ QUnit.test("autoUpdatingRelativeAge", function(assert) {
|
||||
assert.equal($elem.html(), "1 day");
|
||||
});
|
||||
|
||||
QUnit.test("updateRelativeAge", function(assert) {
|
||||
QUnit.test("updateRelativeAge", function (assert) {
|
||||
var d = new Date();
|
||||
var $elem = $(autoUpdatingRelativeAge(d));
|
||||
$elem.data("time", d.getTime() - 2 * 60 * 1000);
|
||||
@@ -236,7 +230,7 @@ QUnit.test("updateRelativeAge", function(assert) {
|
||||
assert.equal($elem.html(), "2 mins ago");
|
||||
});
|
||||
|
||||
QUnit.test("number", function(assert) {
|
||||
QUnit.test("number", function (assert) {
|
||||
assert.equal(number(123), "123", "it returns a string version of the number");
|
||||
assert.equal(number("123"), "123", "it works with a string command");
|
||||
assert.equal(number(NaN), "0", "it returns 0 for NaN");
|
||||
@@ -267,7 +261,7 @@ QUnit.test("number", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("durationTiny", function(assert) {
|
||||
QUnit.test("durationTiny", function (assert) {
|
||||
assert.equal(durationTiny(), "—", "undefined is a dash");
|
||||
assert.equal(durationTiny(null), "—", "null is a dash");
|
||||
assert.equal(durationTiny(0), "< 1m", "0 seconds shows as < 1m");
|
||||
|
||||
@@ -6,24 +6,24 @@ import {
|
||||
isAbsoluteURL,
|
||||
getAbsoluteURL,
|
||||
setPrefix,
|
||||
withoutPrefix
|
||||
withoutPrefix,
|
||||
} from "discourse-common/lib/get-url";
|
||||
|
||||
QUnit.module("lib:get-url");
|
||||
|
||||
QUnit.test("isAbsoluteURL", assert => {
|
||||
QUnit.test("isAbsoluteURL", (assert) => {
|
||||
setupURL(null, "https://example.com", "/forum");
|
||||
assert.ok(isAbsoluteURL("https://example.com/test/thing"));
|
||||
assert.ok(!isAbsoluteURL("http://example.com/test/thing"));
|
||||
assert.ok(!isAbsoluteURL("https://discourse.org/test/thing"));
|
||||
});
|
||||
|
||||
QUnit.test("getAbsoluteURL", assert => {
|
||||
QUnit.test("getAbsoluteURL", (assert) => {
|
||||
setupURL(null, "https://example.com", "/forum");
|
||||
assert.equal(getAbsoluteURL("/cool/path"), "https://example.com/cool/path");
|
||||
});
|
||||
|
||||
QUnit.test("withoutPrefix", assert => {
|
||||
QUnit.test("withoutPrefix", (assert) => {
|
||||
setPrefix("/eviltrout");
|
||||
assert.equal(withoutPrefix("/eviltrout/hello"), "/hello");
|
||||
assert.equal(withoutPrefix("/eviltrout/"), "/");
|
||||
@@ -40,7 +40,7 @@ QUnit.test("withoutPrefix", assert => {
|
||||
assert.equal(withoutPrefix("/"), "/");
|
||||
});
|
||||
|
||||
QUnit.test("getURL with empty paths", assert => {
|
||||
QUnit.test("getURL with empty paths", (assert) => {
|
||||
setupURL(null, "https://example.com", "/");
|
||||
assert.equal(getURL("/"), "/");
|
||||
assert.equal(getURL(""), "");
|
||||
@@ -52,7 +52,7 @@ QUnit.test("getURL with empty paths", assert => {
|
||||
assert.equal(getURL(""), "");
|
||||
});
|
||||
|
||||
QUnit.test("getURL on subfolder install", assert => {
|
||||
QUnit.test("getURL on subfolder install", (assert) => {
|
||||
setupURL(null, "", "/forum");
|
||||
assert.equal(getURL("/"), "/forum/", "root url has subfolder");
|
||||
assert.equal(
|
||||
@@ -80,7 +80,7 @@ QUnit.test("getURL on subfolder install", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("getURLWithCDN on subfolder install with S3", assert => {
|
||||
QUnit.test("getURLWithCDN on subfolder install with S3", (assert) => {
|
||||
setupURL(null, "", "/forum");
|
||||
setupS3CDN(
|
||||
"//test.s3-us-west-1.amazonaws.com/site",
|
||||
|
||||
@@ -3,7 +3,7 @@ import { fixture } from "helpers/qunit-helpers";
|
||||
|
||||
QUnit.module("lib:highlight-search");
|
||||
|
||||
QUnit.test("highlighting text", assert => {
|
||||
QUnit.test("highlighting text", (assert) => {
|
||||
fixture().html(
|
||||
`
|
||||
<p>This is some text to highlight</p>
|
||||
@@ -25,7 +25,7 @@ QUnit.test("highlighting text", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("highlighting unicode text", assert => {
|
||||
QUnit.test("highlighting unicode text", (assert) => {
|
||||
fixture().html(
|
||||
`
|
||||
<p>This is some தமிழ் & русский text to highlight</p>
|
||||
|
||||
@@ -14,21 +14,21 @@ QUnit.module("lib:i18n", {
|
||||
js: {
|
||||
topic: {
|
||||
reply: {
|
||||
title: "Foo"
|
||||
}
|
||||
}
|
||||
}
|
||||
title: "Foo",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
fr: {
|
||||
js: {
|
||||
hello: "Bonjour",
|
||||
topic: {
|
||||
reply: {
|
||||
title: "Répondre"
|
||||
title: "Répondre",
|
||||
},
|
||||
share: {
|
||||
title: "Partager"
|
||||
}
|
||||
title: "Partager",
|
||||
},
|
||||
},
|
||||
character_count: {
|
||||
zero: "{{count}} ZERO",
|
||||
@@ -36,40 +36,40 @@ QUnit.module("lib:i18n", {
|
||||
two: "{{count}} TWO",
|
||||
few: "{{count}} FEW",
|
||||
many: "{{count}} MANY",
|
||||
other: "{{count}} OTHER"
|
||||
other: "{{count}} OTHER",
|
||||
},
|
||||
days: {
|
||||
other: "%{count} jours"
|
||||
}
|
||||
}
|
||||
other: "%{count} jours",
|
||||
},
|
||||
},
|
||||
},
|
||||
en: {
|
||||
js: {
|
||||
hello: {
|
||||
world: "Hello World!",
|
||||
universe: ""
|
||||
universe: "",
|
||||
},
|
||||
topic: {
|
||||
reply: {
|
||||
help: "begin composing a reply to this topic"
|
||||
}
|
||||
help: "begin composing a reply to this topic",
|
||||
},
|
||||
},
|
||||
word_count: {
|
||||
one: "1 word",
|
||||
other: "{{count}} words"
|
||||
other: "{{count}} words",
|
||||
},
|
||||
days: {
|
||||
one: "%{count} day",
|
||||
other: "%{count} days"
|
||||
other: "%{count} days",
|
||||
},
|
||||
dollar_sign: "Hi {{description}}"
|
||||
}
|
||||
}
|
||||
dollar_sign: "Hi {{description}}",
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
// fake pluralization rules
|
||||
I18n.pluralizationRules = Object.assign({}, I18n.pluralizationRules);
|
||||
I18n.pluralizationRules.fr = function(n) {
|
||||
I18n.pluralizationRules.fr = function (n) {
|
||||
if (n === 0) return "zero";
|
||||
if (n === 1) return "one";
|
||||
if (n === 2) return "two";
|
||||
@@ -85,15 +85,15 @@ QUnit.module("lib:i18n", {
|
||||
I18n.translations = this._translations;
|
||||
I18n.extras = this._extras;
|
||||
I18n.pluralizationRules = this._pluralizationRules;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test("defaults", assert => {
|
||||
QUnit.test("defaults", (assert) => {
|
||||
assert.equal(I18n.defaultLocale, "en", "it has English as default locale");
|
||||
assert.ok(I18n.pluralizationRules["en"], "it has English pluralizer");
|
||||
});
|
||||
|
||||
QUnit.test("translations", assert => {
|
||||
QUnit.test("translations", (assert) => {
|
||||
assert.equal(
|
||||
I18n.t("topic.reply.title"),
|
||||
"Répondre",
|
||||
@@ -112,7 +112,7 @@ QUnit.test("translations", assert => {
|
||||
assert.equal(I18n.t("hello.universe"), "", "allows empty strings");
|
||||
});
|
||||
|
||||
QUnit.test("extra translations", assert => {
|
||||
QUnit.test("extra translations", (assert) => {
|
||||
I18n.locale = "pl_PL";
|
||||
I18n.extras = {
|
||||
en: {
|
||||
@@ -121,23 +121,23 @@ QUnit.test("extra translations", assert => {
|
||||
title: "Dashboard",
|
||||
backup_count: {
|
||||
one: "%{count} backup",
|
||||
other: "%{count} backups"
|
||||
}
|
||||
other: "%{count} backups",
|
||||
},
|
||||
},
|
||||
web_hooks: {
|
||||
events: {
|
||||
incoming: {
|
||||
one: "There is a new event.",
|
||||
other: "There are %{count} new events."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
other: "There are %{count} new events.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
pl_PL: {
|
||||
admin: {
|
||||
dashboard: {
|
||||
title: "Raporty"
|
||||
title: "Raporty",
|
||||
},
|
||||
web_hooks: {
|
||||
events: {
|
||||
@@ -145,14 +145,14 @@ QUnit.test("extra translations", assert => {
|
||||
one: "Istnieje nowe wydarzenie",
|
||||
few: "Istnieją %{count} nowe wydarzenia.",
|
||||
many: "Istnieje %{count} nowych wydarzeń.",
|
||||
other: "Istnieje %{count} nowych wydarzeń."
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
other: "Istnieje %{count} nowych wydarzeń.",
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
I18n.pluralizationRules.pl_PL = function(n) {
|
||||
I18n.pluralizationRules.pl_PL = function (n) {
|
||||
if (n === 1) return "one";
|
||||
if (n % 10 >= 2 && n % 10 <= 4) return "few";
|
||||
if (n % 10 === 0) return "many";
|
||||
@@ -178,7 +178,7 @@ QUnit.test("extra translations", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("pluralizations", assert => {
|
||||
QUnit.test("pluralizations", (assert) => {
|
||||
assert.equal(I18n.t("character_count", { count: 0 }), "0 ZERO");
|
||||
assert.equal(I18n.t("character_count", { count: 1 }), "1 ONE");
|
||||
assert.equal(I18n.t("character_count", { count: 2 }), "2 TWO");
|
||||
@@ -194,7 +194,7 @@ QUnit.test("pluralizations", assert => {
|
||||
assert.equal(I18n.t("word_count", { count: 100 }), "100 words");
|
||||
});
|
||||
|
||||
QUnit.test("fallback", assert => {
|
||||
QUnit.test("fallback", (assert) => {
|
||||
assert.equal(
|
||||
I18n.t("days", { count: 1 }),
|
||||
"1 day",
|
||||
@@ -226,10 +226,10 @@ QUnit.test("fallback", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Dollar signs are properly escaped", assert => {
|
||||
QUnit.test("Dollar signs are properly escaped", (assert) => {
|
||||
assert.equal(
|
||||
I18n.t("dollar_sign", {
|
||||
description: "$& $&"
|
||||
description: "$& $&",
|
||||
}),
|
||||
"Hi $& $&"
|
||||
);
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import {
|
||||
iconHTML,
|
||||
iconNode,
|
||||
convertIconClass
|
||||
convertIconClass,
|
||||
} from "discourse-common/lib/icon-library";
|
||||
|
||||
QUnit.module("lib:icon-library");
|
||||
|
||||
QUnit.test("return icon markup", assert => {
|
||||
QUnit.test("return icon markup", (assert) => {
|
||||
assert.ok(iconHTML("bars").indexOf('use xlink:href="#bars"') > -1);
|
||||
|
||||
const nodeIcon = iconNode("bars");
|
||||
@@ -17,7 +17,7 @@ QUnit.test("return icon markup", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("convert icon names", assert => {
|
||||
QUnit.test("convert icon names", (assert) => {
|
||||
const fa5Icon = convertIconClass("fab fa-facebook");
|
||||
assert.ok(iconHTML(fa5Icon).indexOf("fab-facebook") > -1, "FA 5 syntax");
|
||||
|
||||
|
||||
@@ -2,13 +2,13 @@ import KeyValueStore from "discourse/lib/key-value-store";
|
||||
|
||||
QUnit.module("lib:key-value-store");
|
||||
|
||||
QUnit.test("it's able to get the result back from the store", assert => {
|
||||
QUnit.test("it's able to get the result back from the store", (assert) => {
|
||||
const store = new KeyValueStore("_test");
|
||||
store.set({ key: "bob", value: "uncle" });
|
||||
assert.equal(store.get("bob"), "uncle");
|
||||
});
|
||||
|
||||
QUnit.test("is able to nuke the store", assert => {
|
||||
QUnit.test("is able to nuke the store", (assert) => {
|
||||
const store = new KeyValueStore("_test");
|
||||
store.set({ key: "bob1", value: "uncle" });
|
||||
store.abandonLocal();
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
import {
|
||||
fetchUnseenMentions,
|
||||
linkSeenMentions
|
||||
linkSeenMentions,
|
||||
} from "discourse/lib/link-mentions";
|
||||
import { Promise } from "rsvp";
|
||||
import pretender from "helpers/create-pretender";
|
||||
|
||||
QUnit.module("lib:link-mentions");
|
||||
|
||||
QUnit.test("linkSeenMentions replaces users and groups", async assert => {
|
||||
QUnit.test("linkSeenMentions replaces users and groups", async (assert) => {
|
||||
pretender.get("/u/is_local_username", () => [
|
||||
200,
|
||||
{ "Content-Type": "application/json" },
|
||||
@@ -17,19 +17,19 @@ QUnit.test("linkSeenMentions replaces users and groups", async assert => {
|
||||
mentionable_groups: [
|
||||
{
|
||||
name: "mentionable_group",
|
||||
user_count: 1
|
||||
}
|
||||
user_count: 1,
|
||||
},
|
||||
],
|
||||
cannot_see: [],
|
||||
max_users_notified_per_group_mention: 100
|
||||
}
|
||||
max_users_notified_per_group_mention: 100,
|
||||
},
|
||||
]);
|
||||
|
||||
await fetchUnseenMentions([
|
||||
"valid_user",
|
||||
"mentionable_group",
|
||||
"valid_group",
|
||||
"invalid"
|
||||
"invalid",
|
||||
]);
|
||||
|
||||
let $root = $(`
|
||||
@@ -45,7 +45,7 @@ QUnit.test("linkSeenMentions replaces users and groups", async assert => {
|
||||
|
||||
// Ember.Test.registerWaiter is not available here, so we are implementing
|
||||
// our own
|
||||
await new Promise(resolve => {
|
||||
await new Promise((resolve) => {
|
||||
const interval = setInterval(() => {
|
||||
if ($("a", $root).length > 0) {
|
||||
clearInterval(interval);
|
||||
|
||||
@@ -4,7 +4,7 @@ QUnit.module("lib:load-script");
|
||||
|
||||
QUnit.skip(
|
||||
"load with a script tag, and callbacks are only executed after script is loaded",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
assert.ok(
|
||||
typeof window.ace === "undefined",
|
||||
"ensures ace is not previously loaded"
|
||||
|
||||
@@ -10,13 +10,13 @@ function loadOnebox(element) {
|
||||
ajax,
|
||||
synchronous: true,
|
||||
categoryId: 1,
|
||||
topicId: 1
|
||||
topicId: 1,
|
||||
});
|
||||
}
|
||||
|
||||
QUnit.module("lib:oneboxer");
|
||||
|
||||
QUnit.test("load - failed onebox", async assert => {
|
||||
QUnit.test("load - failed onebox", async (assert) => {
|
||||
let element = document.createElement("A");
|
||||
element.setAttribute("href", "http://somebadurl.com");
|
||||
|
||||
@@ -34,7 +34,7 @@ QUnit.test("load - failed onebox", async assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("load - successful onebox", async assert => {
|
||||
QUnit.test("load - successful onebox", async (assert) => {
|
||||
const html = `
|
||||
<aside class="onebox allowlistedgeneric">
|
||||
<header class="source">
|
||||
|
||||
@@ -4,10 +4,10 @@ import { Promise } from "rsvp";
|
||||
QUnit.module("preload-store", {
|
||||
beforeEach() {
|
||||
PreloadStore.store("bane", "evil");
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test("get", assert => {
|
||||
QUnit.test("get", (assert) => {
|
||||
assert.blank(PreloadStore.get("joker"), "returns blank for a missing key");
|
||||
assert.equal(
|
||||
PreloadStore.get("bane"),
|
||||
@@ -16,21 +16,21 @@ QUnit.test("get", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("remove", assert => {
|
||||
QUnit.test("remove", (assert) => {
|
||||
PreloadStore.remove("bane");
|
||||
assert.blank(PreloadStore.get("bane"), "removes the value if the key exists");
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"getAndRemove returns a promise that resolves to null",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
assert.blank(await PreloadStore.getAndRemove("joker"));
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test(
|
||||
"getAndRemove returns a promise that resolves to the result of the finder",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
const finder = () => "batdance";
|
||||
const result = await PreloadStore.getAndRemove("joker", finder);
|
||||
|
||||
@@ -40,7 +40,7 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"getAndRemove returns a promise that resolves to the result of the finder's promise",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
const finder = () => Promise.resolve("hahahah");
|
||||
const result = await PreloadStore.getAndRemove("joker", finder);
|
||||
|
||||
@@ -50,16 +50,16 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"returns a promise that rejects with the result of the finder's rejected promise",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
const finder = () => Promise.reject("error");
|
||||
|
||||
await PreloadStore.getAndRemove("joker", finder).catch(result => {
|
||||
await PreloadStore.getAndRemove("joker", finder).catch((result) => {
|
||||
assert.equal(result, "error");
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("returns a promise that resolves to 'evil'", async assert => {
|
||||
QUnit.test("returns a promise that resolves to 'evil'", async (assert) => {
|
||||
const result = await PreloadStore.getAndRemove("bane");
|
||||
assert.equal(result, "evil");
|
||||
});
|
||||
|
||||
@@ -4,7 +4,7 @@ import PrettyText, { buildOptions } from "pretty-text/pretty-text";
|
||||
import { IMAGE_VERSION as v } from "pretty-text/emoji/version";
|
||||
import {
|
||||
applyCachedInlineOnebox,
|
||||
deleteCachedInlineOnebox
|
||||
deleteCachedInlineOnebox,
|
||||
} from "pretty-text/inline-oneboxer";
|
||||
import { extractDataAttribute } from "pretty-text/engines/discourse-markdown-it";
|
||||
import { registerEmoji } from "pretty-text/emoji";
|
||||
@@ -21,39 +21,39 @@ const rawOpts = {
|
||||
highlighted_languages: "json|ruby|javascript",
|
||||
default_code_lang: "auto",
|
||||
enable_markdown_linkify: true,
|
||||
markdown_linkify_tlds: "com"
|
||||
markdown_linkify_tlds: "com",
|
||||
},
|
||||
getURL: url => url
|
||||
getURL: (url) => url,
|
||||
};
|
||||
|
||||
const defaultOpts = buildOptions(rawOpts);
|
||||
|
||||
QUnit.assert.cooked = function(input, expected, message) {
|
||||
QUnit.assert.cooked = function (input, expected, message) {
|
||||
const actual = new PrettyText(defaultOpts).cook(input);
|
||||
this.pushResult({
|
||||
result: actual === expected.replace(/\/>/g, ">"),
|
||||
actual,
|
||||
expected,
|
||||
message
|
||||
message,
|
||||
});
|
||||
};
|
||||
|
||||
QUnit.assert.cookedOptions = function(input, opts, expected, message) {
|
||||
QUnit.assert.cookedOptions = function (input, opts, expected, message) {
|
||||
const merged = deepMerge({}, rawOpts, opts);
|
||||
const actual = new PrettyText(buildOptions(merged)).cook(input);
|
||||
this.pushResult({
|
||||
result: actual === expected,
|
||||
actual,
|
||||
expected,
|
||||
message
|
||||
message,
|
||||
});
|
||||
};
|
||||
|
||||
QUnit.assert.cookedPara = function(input, expected, message) {
|
||||
QUnit.assert.cookedPara = function (input, expected, message) {
|
||||
QUnit.assert.cooked(input, `<p>${expected}</p>`, message);
|
||||
};
|
||||
|
||||
QUnit.skip("Pending Engine fixes and spec fixes", assert => {
|
||||
QUnit.skip("Pending Engine fixes and spec fixes", (assert) => {
|
||||
assert.cooked(
|
||||
"Derpy: http://derp.com?_test_=1",
|
||||
'<p>Derpy: <a href=https://derp.com?_test_=1"http://derp.com?_test_=1">http://derp.com?_test_=1</a></p>',
|
||||
@@ -67,7 +67,7 @@ QUnit.skip("Pending Engine fixes and spec fixes", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("buildOptions", assert => {
|
||||
QUnit.test("buildOptions", (assert) => {
|
||||
assert.ok(
|
||||
buildOptions({ siteSettings: { enable_emoji: true } }).discourse.features
|
||||
.emoji,
|
||||
@@ -80,7 +80,7 @@ QUnit.test("buildOptions", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("basic cooking", assert => {
|
||||
QUnit.test("basic cooking", (assert) => {
|
||||
assert.cooked("hello", "<p>hello</p>", "surrounds text with paragraphs");
|
||||
assert.cooked("**evil**", "<p><strong>evil</strong></p>", "it bolds text.");
|
||||
assert.cooked("__bold__", "<p><strong>bold</strong></p>", "it bolds text.");
|
||||
@@ -118,7 +118,7 @@ QUnit.test("basic cooking", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Nested bold and italics", assert => {
|
||||
QUnit.test("Nested bold and italics", (assert) => {
|
||||
assert.cooked(
|
||||
"*this is italic **with some bold** inside*",
|
||||
"<p><em>this is italic <strong>with some bold</strong> inside</em></p>",
|
||||
@@ -126,7 +126,7 @@ QUnit.test("Nested bold and italics", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Traditional Line Breaks", assert => {
|
||||
QUnit.test("Traditional Line Breaks", (assert) => {
|
||||
const input = "1\n2\n3";
|
||||
assert.cooked(
|
||||
input,
|
||||
@@ -140,14 +140,14 @@ QUnit.test("Traditional Line Breaks", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Unbalanced underscores", assert => {
|
||||
QUnit.test("Unbalanced underscores", (assert) => {
|
||||
assert.cooked(
|
||||
"[evil_trout][1] hello_\n\n[1]: http://eviltrout.com",
|
||||
'<p><a href="http://eviltrout.com">evil_trout</a> hello_</p>'
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Line Breaks", assert => {
|
||||
QUnit.test("Line Breaks", (assert) => {
|
||||
assert.cooked(
|
||||
"[] first choice\n[] second choice",
|
||||
"<p>[] first choice<br>\n[] second choice</p>",
|
||||
@@ -171,7 +171,7 @@ QUnit.test("Line Breaks", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Paragraphs for HTML", assert => {
|
||||
QUnit.test("Paragraphs for HTML", (assert) => {
|
||||
assert.cooked(
|
||||
"<div>hello world</div>",
|
||||
"<div>hello world</div>",
|
||||
@@ -194,7 +194,7 @@ QUnit.test("Paragraphs for HTML", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Links", assert => {
|
||||
QUnit.test("Links", (assert) => {
|
||||
assert.cooked(
|
||||
"EvilTrout: http://eviltrout.com",
|
||||
'<p>EvilTrout: <a href="http://eviltrout.com">http://eviltrout.com</a></p>',
|
||||
@@ -343,7 +343,7 @@ QUnit.test("Links", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("simple quotes", assert => {
|
||||
QUnit.test("simple quotes", (assert) => {
|
||||
assert.cooked(
|
||||
"> nice!",
|
||||
"<blockquote>\n<p>nice!</p>\n</blockquote>",
|
||||
@@ -392,7 +392,7 @@ eviltrout</p>
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Quotes", assert => {
|
||||
QUnit.test("Quotes", (assert) => {
|
||||
assert.cookedOptions(
|
||||
'[quote="eviltrout, post: 1"]\na quote\n\nsecond line\n\nthird line\n[/quote]',
|
||||
{ topicId: 2 },
|
||||
@@ -411,7 +411,7 @@ QUnit.test("Quotes", assert => {
|
||||
|
||||
assert.cookedOptions(
|
||||
'[quote="bob, post:1"]\nmy quote\n[/quote]',
|
||||
{ topicId: 2, lookupAvatar: function() {} },
|
||||
{ topicId: 2, lookupAvatar: function () {} },
|
||||
`<aside class=\"quote no-group\" data-username=\"bob\" data-post=\"1\">
|
||||
<div class=\"title\">
|
||||
<div class=\"quote-controls\"></div>
|
||||
@@ -453,7 +453,7 @@ QUnit.test("Quotes", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Mentions", assert => {
|
||||
QUnit.test("Mentions", (assert) => {
|
||||
assert.cooked(
|
||||
"Hello @sam",
|
||||
'<p>Hello <span class="mention">@sam</span></p>',
|
||||
@@ -594,7 +594,7 @@ QUnit.test("Mentions", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Mentions - Unicode usernames enabled", assert => {
|
||||
QUnit.test("Mentions - Unicode usernames enabled", (assert) => {
|
||||
assert.cookedOptions(
|
||||
"Hello @狮子",
|
||||
{ siteSettings: { unicode_usernames: true } },
|
||||
@@ -617,7 +617,7 @@ QUnit.test("Mentions - Unicode usernames enabled", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Mentions - disabled", assert => {
|
||||
QUnit.test("Mentions - disabled", (assert) => {
|
||||
assert.cookedOptions(
|
||||
"@eviltrout",
|
||||
{ siteSettings: { enable_mentions: false } },
|
||||
@@ -625,11 +625,11 @@ QUnit.test("Mentions - disabled", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Category hashtags", assert => {
|
||||
QUnit.test("Category hashtags", (assert) => {
|
||||
const alwaysTrue = {
|
||||
categoryHashtagLookup: function() {
|
||||
categoryHashtagLookup: function () {
|
||||
return ["http://test.discourse.org/category-hashtag", "category-hashtag"];
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
assert.cookedOptions(
|
||||
@@ -689,7 +689,7 @@ QUnit.test("Category hashtags", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Heading", assert => {
|
||||
QUnit.test("Heading", (assert) => {
|
||||
assert.cooked(
|
||||
"**Bold**\n----------",
|
||||
"<h2><strong>Bold</strong></h2>",
|
||||
@@ -697,7 +697,7 @@ QUnit.test("Heading", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("bold and italics", assert => {
|
||||
QUnit.test("bold and italics", (assert) => {
|
||||
assert.cooked(
|
||||
'a "**hello**"',
|
||||
"<p>a "<strong>hello</strong>"</p>",
|
||||
@@ -735,7 +735,7 @@ QUnit.test("bold and italics", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Escaping", assert => {
|
||||
QUnit.test("Escaping", (assert) => {
|
||||
assert.cooked(
|
||||
"*\\*laughs\\**",
|
||||
"<p><em>*laughs*</em></p>",
|
||||
@@ -748,7 +748,7 @@ QUnit.test("Escaping", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("New Lines", assert => {
|
||||
QUnit.test("New Lines", (assert) => {
|
||||
// historically we would not continue inline em or b across lines,
|
||||
// however commonmark gives us no switch to do so and we would be very non compliant.
|
||||
// turning softbreaks into a newline is just a renderer option, not a parser switch.
|
||||
@@ -764,7 +764,7 @@ QUnit.test("New Lines", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Oneboxing", assert => {
|
||||
QUnit.test("Oneboxing", (assert) => {
|
||||
function matches(input, regexp) {
|
||||
return new PrettyText(defaultOpts).cook(input).match(regexp);
|
||||
}
|
||||
@@ -810,7 +810,7 @@ QUnit.test("Oneboxing", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("links with full urls", assert => {
|
||||
QUnit.test("links with full urls", (assert) => {
|
||||
assert.cooked(
|
||||
"[http://eviltrout.com][1] is a url\n\n[1]: http://eviltrout.com",
|
||||
'<p><a href="http://eviltrout.com">http://eviltrout.com</a> is a url</p>',
|
||||
@@ -818,7 +818,7 @@ QUnit.test("links with full urls", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("Code Blocks", assert => {
|
||||
QUnit.test("Code Blocks", (assert) => {
|
||||
assert.cooked(
|
||||
"<pre>\nhello\n</pre>\n",
|
||||
"<pre>\nhello\n</pre>",
|
||||
@@ -940,7 +940,7 @@ QUnit.test("Code Blocks", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("URLs in BBCode tags", assert => {
|
||||
QUnit.test("URLs in BBCode tags", (assert) => {
|
||||
assert.cooked(
|
||||
"[img]http://eviltrout.com/eviltrout.png[/img][img]http://samsaffron.com/samsaffron.png[/img]",
|
||||
'<p><img src="http://eviltrout.com/eviltrout.png" alt/><img src="http://samsaffron.com/samsaffron.png" alt/></p>',
|
||||
@@ -960,7 +960,7 @@ QUnit.test("URLs in BBCode tags", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("images", assert => {
|
||||
QUnit.test("images", (assert) => {
|
||||
assert.cooked(
|
||||
"[](http://folksy.com/)",
|
||||
'<p><a href="http://folksy.com/"><img src="http://folksy.com/images/folksy-colour.png" alt="folksy logo"/></a></p>',
|
||||
@@ -974,7 +974,7 @@ QUnit.test("images", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("attachment", assert => {
|
||||
QUnit.test("attachment", (assert) => {
|
||||
assert.cooked(
|
||||
"[test.pdf|attachment](upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf)",
|
||||
`<p><a class="attachment" href="/404" data-orig-href="upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf">test.pdf</a></p>`,
|
||||
@@ -982,14 +982,14 @@ QUnit.test("attachment", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("attachment - mapped url - secure media disabled", assert => {
|
||||
QUnit.test("attachment - mapped url - secure media disabled", (assert) => {
|
||||
function lookupUploadUrls() {
|
||||
let cache = {};
|
||||
cache["upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf"] = {
|
||||
short_url: "upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf",
|
||||
url:
|
||||
"/secure-media-uploads/original/3X/c/b/o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf",
|
||||
short_path: "/uploads/short-url/blah"
|
||||
short_path: "/uploads/short-url/blah",
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
@@ -997,21 +997,21 @@ QUnit.test("attachment - mapped url - secure media disabled", assert => {
|
||||
"[test.pdf|attachment](upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf)",
|
||||
{
|
||||
siteSettings: { secure_media: false },
|
||||
lookupUploadUrls: lookupUploadUrls
|
||||
lookupUploadUrls: lookupUploadUrls,
|
||||
},
|
||||
`<p><a class="attachment" href="/uploads/short-url/blah">test.pdf</a></p>`,
|
||||
"It returns the correct attachment link HTML when the URL is mapped without secure media"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("attachment - mapped url - secure media enabled", assert => {
|
||||
QUnit.test("attachment - mapped url - secure media enabled", (assert) => {
|
||||
function lookupUploadUrls() {
|
||||
let cache = {};
|
||||
cache["upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf"] = {
|
||||
short_url: "upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf",
|
||||
url:
|
||||
"/secure-media-uploads/original/3X/c/b/o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf",
|
||||
short_path: "/uploads/short-url/blah"
|
||||
short_path: "/uploads/short-url/blah",
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
@@ -1019,14 +1019,14 @@ QUnit.test("attachment - mapped url - secure media enabled", assert => {
|
||||
"[test.pdf|attachment](upload://o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf)",
|
||||
{
|
||||
siteSettings: { secure_media: true },
|
||||
lookupUploadUrls: lookupUploadUrls
|
||||
lookupUploadUrls: lookupUploadUrls,
|
||||
},
|
||||
`<p><a class="attachment" href="/secure-media-uploads/original/3X/c/b/o8iobpLcW3WSFvVH7YQmyGlKmGM.pdf">test.pdf</a></p>`,
|
||||
"It returns the correct attachment link HTML when the URL is mapped with secure media"
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("video", assert => {
|
||||
QUnit.test("video", (assert) => {
|
||||
assert.cooked(
|
||||
"",
|
||||
`<p><div class="video-container">
|
||||
@@ -1039,13 +1039,13 @@ QUnit.test("video", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("video - mapped url - secure media enabled", assert => {
|
||||
QUnit.test("video - mapped url - secure media enabled", (assert) => {
|
||||
function lookupUploadUrls() {
|
||||
let cache = {};
|
||||
cache["upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4"] = {
|
||||
short_url: "upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp4",
|
||||
url: "/secure-media-uploads/original/3X/c/b/test.mp4",
|
||||
short_path: "/uploads/short-url/blah"
|
||||
short_path: "/uploads/short-url/blah",
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
@@ -1053,7 +1053,7 @@ QUnit.test("video - mapped url - secure media enabled", assert => {
|
||||
"",
|
||||
{
|
||||
siteSettings: { secure_media: true },
|
||||
lookupUploadUrls: lookupUploadUrls
|
||||
lookupUploadUrls: lookupUploadUrls,
|
||||
},
|
||||
`<p><div class="video-container">
|
||||
<video width="100%" height="100%" preload="metadata" controls>
|
||||
@@ -1065,7 +1065,7 @@ QUnit.test("video - mapped url - secure media enabled", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("audio", assert => {
|
||||
QUnit.test("audio", (assert) => {
|
||||
assert.cooked(
|
||||
"",
|
||||
`<p><audio preload="metadata" controls>
|
||||
@@ -1076,13 +1076,13 @@ QUnit.test("audio", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("audio - mapped url - secure media enabled", assert => {
|
||||
QUnit.test("audio - mapped url - secure media enabled", (assert) => {
|
||||
function lookupUploadUrls() {
|
||||
let cache = {};
|
||||
cache["upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp3"] = {
|
||||
short_url: "upload://eyPnj7UzkU0AkGkx2dx8G4YM1Jx.mp3",
|
||||
url: "/secure-media-uploads/original/3X/c/b/test.mp3",
|
||||
short_path: "/uploads/short-url/blah"
|
||||
short_path: "/uploads/short-url/blah",
|
||||
};
|
||||
return cache;
|
||||
}
|
||||
@@ -1090,7 +1090,7 @@ QUnit.test("audio - mapped url - secure media enabled", assert => {
|
||||
"",
|
||||
{
|
||||
siteSettings: { secure_media: true },
|
||||
lookupUploadUrls: lookupUploadUrls
|
||||
lookupUploadUrls: lookupUploadUrls,
|
||||
},
|
||||
`<p><audio preload="metadata" controls>
|
||||
<source src="/secure-media-uploads/original/3X/c/b/test.mp3">
|
||||
@@ -1100,11 +1100,11 @@ QUnit.test("audio - mapped url - secure media enabled", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("censoring", assert => {
|
||||
QUnit.test("censoring", (assert) => {
|
||||
assert.cookedOptions(
|
||||
"Pleased to meet you, but pleeeease call me later, xyz123",
|
||||
{
|
||||
censoredRegexp: "(xyz*|plee+ase)"
|
||||
censoredRegexp: "(xyz*|plee+ase)",
|
||||
},
|
||||
"<p>Pleased to meet you, but ■■■■■■■■■ call me later, ■■■123</p>",
|
||||
"supports censoring"
|
||||
@@ -1112,7 +1112,7 @@ QUnit.test("censoring", assert => {
|
||||
// More tests in pretty_text_spec.rb
|
||||
});
|
||||
|
||||
QUnit.test("code blocks/spans hoisting", assert => {
|
||||
QUnit.test("code blocks/spans hoisting", (assert) => {
|
||||
assert.cooked(
|
||||
"```\n\n some code\n```",
|
||||
'<pre><code class="lang-auto">\n some code\n</code></pre>',
|
||||
@@ -1126,7 +1126,7 @@ QUnit.test("code blocks/spans hoisting", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("basic bbcode", assert => {
|
||||
QUnit.test("basic bbcode", (assert) => {
|
||||
assert.cookedPara(
|
||||
"[b]strong[/b]",
|
||||
'<span class="bbcode-b">strong</span>',
|
||||
@@ -1174,7 +1174,7 @@ QUnit.test("basic bbcode", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("urls", assert => {
|
||||
QUnit.test("urls", (assert) => {
|
||||
assert.cookedPara(
|
||||
"[url]not a url[/url]",
|
||||
"not a url",
|
||||
@@ -1201,7 +1201,7 @@ QUnit.test("urls", assert => {
|
||||
"supports [url] with an embedded [img]"
|
||||
);
|
||||
});
|
||||
QUnit.test("invalid bbcode", assert => {
|
||||
QUnit.test("invalid bbcode", (assert) => {
|
||||
assert.cooked(
|
||||
"[code]I am not closed\n\nThis text exists.",
|
||||
"<p>[code]I am not closed</p>\n<p>This text exists.</p>",
|
||||
@@ -1209,7 +1209,7 @@ QUnit.test("invalid bbcode", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("code", assert => {
|
||||
QUnit.test("code", (assert) => {
|
||||
assert.cooked(
|
||||
"[code]\nx++\n[/code]",
|
||||
'<pre><code class="lang-auto">x++</code></pre>',
|
||||
@@ -1232,7 +1232,7 @@ QUnit.test("code", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("tags with arguments", assert => {
|
||||
QUnit.test("tags with arguments", (assert) => {
|
||||
assert.cookedPara(
|
||||
"[url=http://bettercallsaul.com]better call![/url]",
|
||||
'<a href="http://bettercallsaul.com" data-bbcode="true">better call!</a>',
|
||||
@@ -1255,12 +1255,12 @@ QUnit.test("tags with arguments", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("quotes", assert => {
|
||||
QUnit.test("quotes", (assert) => {
|
||||
const post = Post.create({
|
||||
cooked: "<p><b>lorem</b> ipsum</p>",
|
||||
username: "eviltrout",
|
||||
post_number: 1,
|
||||
topic_id: 2
|
||||
topic_id: 2,
|
||||
});
|
||||
|
||||
function formatQuote(val, expected, text, opts) {
|
||||
@@ -1315,14 +1315,14 @@ QUnit.test("quotes", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("quoting a quote", assert => {
|
||||
QUnit.test("quoting a quote", (assert) => {
|
||||
const post = Post.create({
|
||||
cooked: new PrettyText(defaultOpts).cook(
|
||||
'[quote="sam, post:1, topic:1, full:true"]\nhello\n[/quote]\n*Test*'
|
||||
),
|
||||
username: "eviltrout",
|
||||
post_number: 1,
|
||||
topic_id: 2
|
||||
topic_id: 2,
|
||||
});
|
||||
|
||||
const quote = buildQuote(
|
||||
@@ -1337,7 +1337,7 @@ QUnit.test("quoting a quote", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("quote formatting", assert => {
|
||||
QUnit.test("quote formatting", (assert) => {
|
||||
assert.cooked(
|
||||
'[quote="EvilTrout, post:123, topic:456, full:true"]\n[sam]\n[/quote]',
|
||||
`<aside class=\"quote no-group\" data-username=\"EvilTrout\" data-post=\"123\" data-topic=\"456\" data-full=\"true\">
|
||||
@@ -1440,7 +1440,7 @@ var bar = 'bar';
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("quotes with trailing formatting", assert => {
|
||||
QUnit.test("quotes with trailing formatting", (assert) => {
|
||||
const result = new PrettyText(defaultOpts).cook(
|
||||
'[quote="EvilTrout, post:123, topic:456, full:true"]\nhello\n[/quote]\n*Test*'
|
||||
);
|
||||
@@ -1459,7 +1459,7 @@ QUnit.test("quotes with trailing formatting", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("enable/disable features", assert => {
|
||||
QUnit.test("enable/disable features", (assert) => {
|
||||
assert.cookedOptions("|a|\n--\n|a|", { features: { table: false } }, "");
|
||||
assert.cooked(
|
||||
"|a|\n--\n|a|",
|
||||
@@ -1480,7 +1480,7 @@ QUnit.test("enable/disable features", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("emoji", assert => {
|
||||
QUnit.test("emoji", (assert) => {
|
||||
assert.cooked(
|
||||
":smile:",
|
||||
`<p><img src="/images/emoji/emoji_one/smile.png?v=${v}" title=":smile:" class="emoji only-emoji" alt=":smile:"></p>`
|
||||
@@ -1495,7 +1495,7 @@ QUnit.test("emoji", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("emoji - enable_inline_emoji_translation", assert => {
|
||||
QUnit.test("emoji - enable_inline_emoji_translation", (assert) => {
|
||||
assert.cookedOptions(
|
||||
"test:smile:test",
|
||||
{ siteSettings: { enable_inline_emoji_translation: false } },
|
||||
@@ -1509,7 +1509,7 @@ QUnit.test("emoji - enable_inline_emoji_translation", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("emoji - emojiSet", assert => {
|
||||
QUnit.test("emoji - emojiSet", (assert) => {
|
||||
assert.cookedOptions(
|
||||
":smile:",
|
||||
{ siteSettings: { emoji_set: "twitter" } },
|
||||
@@ -1517,7 +1517,7 @@ QUnit.test("emoji - emojiSet", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("emoji - registerEmoji", assert => {
|
||||
QUnit.test("emoji - registerEmoji", (assert) => {
|
||||
registerEmoji("foo", "/images/d-logo-sketch.png");
|
||||
|
||||
assert.cookedOptions(
|
||||
@@ -1535,7 +1535,7 @@ QUnit.test("emoji - registerEmoji", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("extractDataAttribute", assert => {
|
||||
QUnit.test("extractDataAttribute", (assert) => {
|
||||
assert.deepEqual(extractDataAttribute("foo="), ["data-foo", ""]);
|
||||
assert.deepEqual(extractDataAttribute("foo=bar"), ["data-foo", "bar"]);
|
||||
|
||||
|
||||
@@ -3,13 +3,13 @@ import { hrefAllowed } from "pretty-text/sanitizer";
|
||||
|
||||
QUnit.module("lib:sanitizer");
|
||||
|
||||
QUnit.test("sanitize", assert => {
|
||||
QUnit.test("sanitize", (assert) => {
|
||||
const pt = new PrettyText(
|
||||
buildOptions({
|
||||
siteSettings: {
|
||||
allowed_iframes:
|
||||
"https://www.google.com/maps/embed?|https://www.openstreetmap.org/export/embed.html?"
|
||||
}
|
||||
"https://www.google.com/maps/embed?|https://www.openstreetmap.org/export/embed.html?",
|
||||
},
|
||||
})
|
||||
);
|
||||
const cooked = (input, expected, text) =>
|
||||
@@ -130,7 +130,7 @@ QUnit.test("sanitize", assert => {
|
||||
cooked(`<div dir="rtl">RTL text</div>`, `<div dir="rtl">RTL text</div>`);
|
||||
});
|
||||
|
||||
QUnit.test("ids on headings", assert => {
|
||||
QUnit.test("ids on headings", (assert) => {
|
||||
const pt = new PrettyText(buildOptions({ siteSettings: {} }));
|
||||
assert.equal(pt.sanitize("<h3>Test Heading</h3>"), "<h3>Test Heading</h3>");
|
||||
assert.equal(
|
||||
@@ -159,7 +159,7 @@ QUnit.test("ids on headings", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("poorly formed ids on headings", assert => {
|
||||
QUnit.test("poorly formed ids on headings", (assert) => {
|
||||
let pt = new PrettyText(buildOptions({ siteSettings: {} }));
|
||||
assert.equal(
|
||||
pt.sanitize(`<h1 id="evil-trout">Test Heading</h1>`),
|
||||
@@ -187,7 +187,7 @@ QUnit.test("poorly formed ids on headings", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("urlAllowed", assert => {
|
||||
QUnit.test("urlAllowed", (assert) => {
|
||||
const allowed = (url, msg) => assert.equal(hrefAllowed(url), url, msg);
|
||||
|
||||
allowed("/foo/bar.html", "allows relative urls");
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
import I18n from "I18n";
|
||||
import {
|
||||
translateResults,
|
||||
searchContextDescription
|
||||
searchContextDescription,
|
||||
} from "discourse/lib/search";
|
||||
|
||||
QUnit.module("lib:search");
|
||||
|
||||
QUnit.test("unescapesEmojisInBlurbs", assert => {
|
||||
QUnit.test("unescapesEmojisInBlurbs", (assert) => {
|
||||
const source = {
|
||||
posts: [
|
||||
{
|
||||
@@ -17,15 +17,15 @@ QUnit.test("unescapesEmojisInBlurbs", assert => {
|
||||
like_count: 1,
|
||||
blurb: ":thinking: This here is a test of emojis in search blurbs.",
|
||||
post_number: 1,
|
||||
topic_id: 41
|
||||
}
|
||||
topic_id: 41,
|
||||
},
|
||||
],
|
||||
topics: [],
|
||||
users: [],
|
||||
categories: [],
|
||||
tags: [],
|
||||
groups: [],
|
||||
grouped_search_result: false
|
||||
grouped_search_result: false,
|
||||
};
|
||||
|
||||
const results = translateResults(source);
|
||||
@@ -36,7 +36,7 @@ QUnit.test("unescapesEmojisInBlurbs", assert => {
|
||||
assert.ok(blurb.indexOf(":thinking:") === -1);
|
||||
});
|
||||
|
||||
QUnit.test("searchContextDescription", assert => {
|
||||
QUnit.test("searchContextDescription", (assert) => {
|
||||
assert.equal(
|
||||
searchContextDescription("topic"),
|
||||
I18n.t("search.context.topic")
|
||||
|
||||
@@ -6,28 +6,28 @@ QUnit.module("lib:sharing", {
|
||||
},
|
||||
afterEach() {
|
||||
Sharing._reset();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test("addSource", assert => {
|
||||
QUnit.test("addSource", (assert) => {
|
||||
const sharingSettings = "facebook|twitter";
|
||||
|
||||
assert.blank(Sharing.activeSources(sharingSettings));
|
||||
|
||||
Sharing.addSource({
|
||||
id: "facebook"
|
||||
id: "facebook",
|
||||
});
|
||||
|
||||
assert.equal(Sharing.activeSources(sharingSettings).length, 1);
|
||||
});
|
||||
|
||||
QUnit.test("addSharingId", assert => {
|
||||
QUnit.test("addSharingId", (assert) => {
|
||||
const sharingSettings = "";
|
||||
|
||||
assert.blank(Sharing.activeSources(sharingSettings));
|
||||
|
||||
Sharing.addSource({
|
||||
id: "new-source"
|
||||
id: "new-source",
|
||||
});
|
||||
|
||||
assert.blank(
|
||||
@@ -46,7 +46,7 @@ QUnit.test("addSharingId", assert => {
|
||||
const privateContext = true;
|
||||
|
||||
Sharing.addSource({
|
||||
id: "another-source"
|
||||
id: "another-source",
|
||||
});
|
||||
Sharing.addSharingId("another-source");
|
||||
|
||||
@@ -58,7 +58,7 @@ QUnit.test("addSharingId", assert => {
|
||||
|
||||
Sharing.addSource({
|
||||
id: "a-private-friendly-source",
|
||||
showInPrivateContext: true
|
||||
showInPrivateContext: true,
|
||||
});
|
||||
Sharing.addSharingId("a-private-friendly-source");
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { isRTL, isLTR } from "discourse/lib/text-direction";
|
||||
|
||||
QUnit.module("lib:text-direction");
|
||||
|
||||
QUnit.test("isRTL", assert => {
|
||||
QUnit.test("isRTL", (assert) => {
|
||||
// Hebrew
|
||||
assert.equal(isRTL("זה מבחן"), true);
|
||||
|
||||
@@ -16,7 +16,7 @@ QUnit.test("isRTL", assert => {
|
||||
assert.equal(isRTL(""), false);
|
||||
});
|
||||
|
||||
QUnit.test("isLTR", assert => {
|
||||
QUnit.test("isLTR", (assert) => {
|
||||
assert.equal(isLTR("This is a test"), true);
|
||||
assert.equal(isLTR("זה מבחן"), false);
|
||||
});
|
||||
|
||||
@@ -2,7 +2,7 @@ import toMarkdown from "discourse/lib/to-markdown";
|
||||
|
||||
QUnit.module("lib:to-markdown");
|
||||
|
||||
QUnit.test("converts styles between normal words", assert => {
|
||||
QUnit.test("converts styles between normal words", (assert) => {
|
||||
const html = `Line with <s>styles</s> <b><i>between</i></b> words.`;
|
||||
const markdown = `Line with ~~styles~~ ***between*** words.`;
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
@@ -10,7 +10,7 @@ QUnit.test("converts styles between normal words", assert => {
|
||||
assert.equal(toMarkdown("A <b>bold </b>word"), "A **bold** word");
|
||||
});
|
||||
|
||||
QUnit.test("converts inline nested styles", assert => {
|
||||
QUnit.test("converts inline nested styles", (assert) => {
|
||||
let html = `<em>Italicised line with <strong>some random</strong> <b>bold</b> words.</em>`;
|
||||
let markdown = `*Italicised line with **some random** **bold** words.*`;
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
@@ -22,7 +22,7 @@ QUnit.test("converts inline nested styles", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("converts a link", assert => {
|
||||
QUnit.test("converts a link", (assert) => {
|
||||
let html = `<a href="https://discourse.org">Discourse</a>`;
|
||||
let markdown = `[Discourse](https://discourse.org)`;
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
@@ -32,7 +32,7 @@ QUnit.test("converts a link", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("put raw URL instead of converting the link", assert => {
|
||||
QUnit.test("put raw URL instead of converting the link", (assert) => {
|
||||
let url = "https://discourse.org";
|
||||
const html = () => `<a href="${url}">${url}</a>`;
|
||||
|
||||
@@ -42,11 +42,11 @@ QUnit.test("put raw URL instead of converting the link", assert => {
|
||||
assert.equal(toMarkdown(html()), url);
|
||||
});
|
||||
|
||||
QUnit.test("skip empty link", assert => {
|
||||
QUnit.test("skip empty link", (assert) => {
|
||||
assert.equal(toMarkdown(`<a href="https://example.com"></a>`), "");
|
||||
});
|
||||
|
||||
QUnit.test("converts heading tags", assert => {
|
||||
QUnit.test("converts heading tags", (assert) => {
|
||||
const html = `
|
||||
<h1>Heading 1</h1>
|
||||
<h2>Heading 2</h2>
|
||||
@@ -69,7 +69,7 @@ QUnit.test("converts heading tags", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("converts ul list tag", assert => {
|
||||
QUnit.test("converts ul list tag", (assert) => {
|
||||
let html = `
|
||||
<ul>
|
||||
<li>Item 1</li>
|
||||
@@ -101,7 +101,7 @@ QUnit.test("converts ul list tag", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("stripes unwanted inline tags", assert => {
|
||||
QUnit.test("stripes unwanted inline tags", (assert) => {
|
||||
const html = `
|
||||
<p>Lorem ipsum <span>dolor sit amet, consectetur</span> <strike>elit.</strike></p>
|
||||
<p>Ut minim veniam, <label>quis nostrud</label> laboris <nisi> ut aliquip ex ea</nisi> commodo.</p>
|
||||
@@ -110,7 +110,7 @@ QUnit.test("stripes unwanted inline tags", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("converts table tags", assert => {
|
||||
QUnit.test("converts table tags", (assert) => {
|
||||
let html = `<address>Discourse Avenue</address><b>laboris</b>
|
||||
<table>
|
||||
<thead> <tr><th>Heading 1</th><th>Head 2</th></tr> </thead>
|
||||
@@ -134,7 +134,7 @@ QUnit.test("converts table tags", assert => {
|
||||
|
||||
QUnit.test(
|
||||
"replace pipes with spaces if table format not supported",
|
||||
assert => {
|
||||
(assert) => {
|
||||
let html = `<table>
|
||||
<thead> <tr><th>Headi<br><br>ng 1</th><th>Head 2</th></tr> </thead>
|
||||
<tbody>
|
||||
@@ -161,7 +161,7 @@ QUnit.test(
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("converts img tag", assert => {
|
||||
QUnit.test("converts img tag", (assert) => {
|
||||
const url = "https://example.com/image.png";
|
||||
const base62SHA1 = "q16M6GR110R47Z9p9Dk3PMXOJoE";
|
||||
let html = `<img src="${url}" width="100" height="50">`;
|
||||
@@ -198,7 +198,7 @@ QUnit.test("converts img tag", assert => {
|
||||
assert.equal(toMarkdown(html), ``);
|
||||
});
|
||||
|
||||
QUnit.test("supporting html tags by keeping them", assert => {
|
||||
QUnit.test("supporting html tags by keeping them", (assert) => {
|
||||
let html =
|
||||
"Lorem <del>ipsum dolor</del> sit <big>amet, <ins>consectetur</ins></big>";
|
||||
let output = html;
|
||||
@@ -222,7 +222,7 @@ QUnit.test("supporting html tags by keeping them", assert => {
|
||||
assert.equal(toMarkdown(html), output);
|
||||
});
|
||||
|
||||
QUnit.test("converts code tags", assert => {
|
||||
QUnit.test("converts code tags", (assert) => {
|
||||
let html = `Lorem ipsum dolor sit amet,
|
||||
<pre><code>var helloWorld = () => {
|
||||
alert(' hello \t\t world ');
|
||||
@@ -244,7 +244,7 @@ helloWorld();</code>consectetur.`;
|
||||
assert.equal(toMarkdown(html), output);
|
||||
});
|
||||
|
||||
QUnit.test("converts blockquote tag", assert => {
|
||||
QUnit.test("converts blockquote tag", (assert) => {
|
||||
let html = "<blockquote>Lorem ipsum</blockquote>";
|
||||
let output = "> Lorem ipsum";
|
||||
assert.equal(toMarkdown(html), output);
|
||||
@@ -260,7 +260,7 @@ QUnit.test("converts blockquote tag", assert => {
|
||||
assert.equal(toMarkdown(html), output);
|
||||
});
|
||||
|
||||
QUnit.test("converts ol list tag", assert => {
|
||||
QUnit.test("converts ol list tag", (assert) => {
|
||||
const html = `Testing
|
||||
<ol>
|
||||
<li>Item 1</li>
|
||||
@@ -278,7 +278,7 @@ QUnit.test("converts ol list tag", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("converts list tag from word", assert => {
|
||||
QUnit.test("converts list tag from word", (assert) => {
|
||||
const html = `Sample<!--StartFragment-->
|
||||
<p class=MsoListParagraphCxSpFirst style='text-indent:-.25in;mso-list:l0 level1 lfo1'>
|
||||
<![if !supportLists]>
|
||||
@@ -325,7 +325,7 @@ QUnit.test("converts list tag from word", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("keeps mention/hash class", assert => {
|
||||
QUnit.test("keeps mention/hash class", (assert) => {
|
||||
const html = `
|
||||
<p>User mention: <a class="mention" href="/u/discourse">@discourse</a></p>
|
||||
<p>Group mention: <a class="mention-group" href="/groups/discourse">@discourse-group</a></p>
|
||||
@@ -338,7 +338,7 @@ QUnit.test("keeps mention/hash class", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("keeps emoji and removes click count", assert => {
|
||||
QUnit.test("keeps emoji and removes click count", (assert) => {
|
||||
const html = `
|
||||
<p>
|
||||
A <a href="http://example.com">link</a><span class="badge badge-notification clicks" title="1 click">1</span> with click count
|
||||
@@ -351,7 +351,7 @@ QUnit.test("keeps emoji and removes click count", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("keeps emoji syntax for custom emoji", assert => {
|
||||
QUnit.test("keeps emoji syntax for custom emoji", (assert) => {
|
||||
const html = `
|
||||
<p>
|
||||
<img class="emoji emoji-custom" title=":custom_emoji:" src="https://d11a6trkgmumsb.cloudfront.net/images/emoji/custom_emoji" alt=":custom_emoji:" />
|
||||
@@ -363,7 +363,7 @@ QUnit.test("keeps emoji syntax for custom emoji", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("converts image lightboxes to markdown", assert => {
|
||||
QUnit.test("converts image lightboxes to markdown", (assert) => {
|
||||
let html = `
|
||||
<a class="lightbox" href="https://d11a6trkgmumsb.cloudfront.net/uploads/default/original/1X/8hkjhk7692f6afed3cb99d43ab2abd4e30aa8cba.jpeg" data-download-href="https://d11a6trkgmumsb.cloudfront.net/uploads/default/8hkjhk7692f6afed3cb99d43ab2abd4e30aa8cba" title="sherlock3_sig.jpg" rel="nofollow noopener"><img src="https://d11a6trkgmumsb.cloudfront.net/uploads/default/optimized/1X/8hkjhk7692f6afed3cb99d43ab2abd4e30aa8cba_2_689x459.jpeg" alt="sherlock3_sig" width="689" height="459" class="d-lazyload" srcset="https://d11a6trkgmumsb.cloudfront.net/uploads/default/optimized/1X/8hkjhk7692f6afed3cb99d43ab2abd4e30aa8cba_2_689x459.jpeg, https://d11a6trkgmumsb.cloudfront.net/uploads/default/optimized/1X/8hkjhk7692f6afed3cb99d43ab2abd4e30aa8cba_2_1033x688.jpeg 1.5x, https://d11a6trkgmumsb.cloudfront.net/uploads/default/optimized/1X/8hkjhk7692f6afed3cb99d43ab2abd4e30aa8cba_2_1378x918.jpeg 2x"><div class="meta">
|
||||
<span class="filename">sherlock3_sig.jpg</span><span class="informations">5496×3664 2 MB</span><span class="expand"></span>
|
||||
@@ -387,7 +387,7 @@ QUnit.test("converts image lightboxes to markdown", assert => {
|
||||
assert.equal(toMarkdown(html), markdown);
|
||||
});
|
||||
|
||||
QUnit.test("converts quotes to markdown", assert => {
|
||||
QUnit.test("converts quotes to markdown", (assert) => {
|
||||
let html = `
|
||||
<p>there is a quote below</p>
|
||||
<aside class="quote no-group" data-username="foo" data-post="1" data-topic="2">
|
||||
@@ -414,7 +414,7 @@ there is a quote above
|
||||
assert.equal(toMarkdown(html), markdown.trim());
|
||||
});
|
||||
|
||||
QUnit.test("strips base64 image URLs", assert => {
|
||||
QUnit.test("strips base64 image URLs", (assert) => {
|
||||
const html =
|
||||
'<img src="data:image/jpeg;base64,/9j/4AAQSkZJRgABAgAAZABkAAD/7AARRHVja3kAAQAEAAAAPAAA/+4AJkFkb2JlAGTAAAAAAQMAFQQDBgoNAAABywAAAgsAAAJpAAACyf/bAIQABgQEBAUEBgUFBgkGBQYJCwgGBggLDAoKCwoKDBAMDAwMDAwQDA4PEA8ODBMTFBQTExwbGxscHx8fHx8fHx8fHwEHBwcNDA0YEBAYGhURFRofHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8fHx8f/8IAEQgAEAAQAwERAAIRAQMRAf/EAJQAAQEBAAAAAAAAAAAAAAAAAAMFBwEAAwEAAAAAAAAAAAAAAAAAAAEDAhAAAQUBAQAAAAAAAAAAAAAAAgABAwQFESARAAIBAwIHAAAAAAAAAAAAAAERAgAhMRIDQWGRocEiIxIBAAAAAAAAAAAAAAAAAAAAIBMBAAMAAQQDAQAAAAAAAAAAAQARITHwQVGBYXGR4f/aAAwDAQACEQMRAAAB0UlMciEJn//aAAgBAQABBQK5bGtFn6pWi2K12wWTRkjb/9oACAECAAEFAvH/2gAIAQMAAQUCIuIJOqRndRiv/9oACAECAgY/Ah//2gAIAQMCBj8CH//aAAgBAQEGPwLWQzwHepfNbcUNfM4tUIbA9QL4AvnxTlAxacpWJReOlf/aAAgBAQMBPyHZDveuCyu4B4lz2lDKto2ca5uclPK0aoq32x8xgTSLeSgbyzT65n//2gAIAQIDAT8hlQjP/9oACAEDAwE/IaE9GcZFJ//aAAwDAQACEQMRAAAQ5F//2gAIAQEDAT8Q1oowKccI3KTdAWkPLw2ssIrwKYUzuJoUJsIHOCoG23ISlja+rU9QvCx//9oACAECAwE/EAuNIiKf/9oACAEDAwE/ECujJzHf7iwHOv5NhK+8efH50z//2Q==" />';
|
||||
assert.equal(toMarkdown(html), "[image]");
|
||||
|
||||
@@ -1,14 +1,14 @@
|
||||
import {
|
||||
lookupCachedUploadUrl,
|
||||
resolveAllShortUrls,
|
||||
resetCache
|
||||
resetCache,
|
||||
} from "pretty-text/upload-short-url";
|
||||
import { ajax } from "discourse/lib/ajax";
|
||||
import { fixture } from "helpers/qunit-helpers";
|
||||
import pretender from "helpers/create-pretender";
|
||||
|
||||
function stubUrls(imageSrcs, attachmentSrcs, otherMediaSrcs) {
|
||||
const response = object => {
|
||||
const response = (object) => {
|
||||
return [200, { "Content-Type": "application/json" }, object];
|
||||
};
|
||||
if (!imageSrcs) {
|
||||
@@ -16,18 +16,18 @@ function stubUrls(imageSrcs, attachmentSrcs, otherMediaSrcs) {
|
||||
{
|
||||
short_url: "upload://a.jpeg",
|
||||
url: "/images/avatar.png?a",
|
||||
short_path: "/uploads/short-url/a.jpeg"
|
||||
short_path: "/uploads/short-url/a.jpeg",
|
||||
},
|
||||
{
|
||||
short_url: "upload://b.jpeg",
|
||||
url: "/images/avatar.png?b",
|
||||
short_path: "/uploads/short-url/b.jpeg"
|
||||
short_path: "/uploads/short-url/b.jpeg",
|
||||
},
|
||||
{
|
||||
short_url: "upload://z.jpeg",
|
||||
url: "/images/avatar.png?z",
|
||||
short_path: "/uploads/short-url/z.jpeg"
|
||||
}
|
||||
short_path: "/uploads/short-url/z.jpeg",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -36,8 +36,8 @@ function stubUrls(imageSrcs, attachmentSrcs, otherMediaSrcs) {
|
||||
{
|
||||
short_url: "upload://c.pdf",
|
||||
url: "/uploads/default/original/3X/c/b/3.pdf",
|
||||
short_path: "/uploads/short-url/c.pdf"
|
||||
}
|
||||
short_path: "/uploads/short-url/c.pdf",
|
||||
},
|
||||
];
|
||||
}
|
||||
|
||||
@@ -46,18 +46,18 @@ function stubUrls(imageSrcs, attachmentSrcs, otherMediaSrcs) {
|
||||
{
|
||||
short_url: "upload://d.mp4",
|
||||
url: "/uploads/default/original/3X/c/b/4.mp4",
|
||||
short_path: "/uploads/short-url/d.mp4"
|
||||
short_path: "/uploads/short-url/d.mp4",
|
||||
},
|
||||
{
|
||||
short_url: "upload://e.mp3",
|
||||
url: "/uploads/default/original/3X/c/b/5.mp3",
|
||||
short_path: "/uploads/short-url/e.mp3"
|
||||
short_path: "/uploads/short-url/e.mp3",
|
||||
},
|
||||
{
|
||||
short_url: "upload://f.mp4",
|
||||
url: "http://localhost:3000/uploads/default/original/3X/c/b/6.mp4",
|
||||
short_path: "/uploads/short-url/f.mp4"
|
||||
}
|
||||
short_path: "/uploads/short-url/f.mp4",
|
||||
},
|
||||
];
|
||||
}
|
||||
// prettier-ignore
|
||||
@@ -66,16 +66,16 @@ function stubUrls(imageSrcs, attachmentSrcs, otherMediaSrcs) {
|
||||
});
|
||||
|
||||
fixture().html(
|
||||
imageSrcs.map(src => `<img data-orig-src="${src.short_url}"/>`).join("") +
|
||||
imageSrcs.map((src) => `<img data-orig-src="${src.short_url}"/>`).join("") +
|
||||
attachmentSrcs
|
||||
.map(
|
||||
src =>
|
||||
(src) =>
|
||||
`<a data-orig-href="${src.short_url}">big enterprise contract.pdf</a>`
|
||||
)
|
||||
.join("") +
|
||||
`<div class="scoped-area"><img data-orig-src="${imageSrcs[2].url}"></div>` +
|
||||
otherMediaSrcs
|
||||
.map(src => {
|
||||
.map((src) => {
|
||||
if (src.short_url.indexOf("mp3") > -1) {
|
||||
return `<audio controls><source data-orig-src="${src.short_url}"></audio>`;
|
||||
} else {
|
||||
@@ -88,10 +88,10 @@ function stubUrls(imageSrcs, attachmentSrcs, otherMediaSrcs) {
|
||||
QUnit.module("lib:pretty-text/upload-short-url", {
|
||||
afterEach() {
|
||||
resetCache();
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test("resolveAllShortUrls", async assert => {
|
||||
QUnit.test("resolveAllShortUrls", async (assert) => {
|
||||
stubUrls();
|
||||
let lookup;
|
||||
|
||||
@@ -104,14 +104,14 @@ QUnit.test("resolveAllShortUrls", async assert => {
|
||||
|
||||
assert.deepEqual(lookup, {
|
||||
url: "/images/avatar.png?a",
|
||||
short_path: "/uploads/short-url/a.jpeg"
|
||||
short_path: "/uploads/short-url/a.jpeg",
|
||||
});
|
||||
|
||||
lookup = lookupCachedUploadUrl("upload://b.jpeg");
|
||||
|
||||
assert.deepEqual(lookup, {
|
||||
url: "/images/avatar.png?b",
|
||||
short_path: "/uploads/short-url/b.jpeg"
|
||||
short_path: "/uploads/short-url/b.jpeg",
|
||||
});
|
||||
|
||||
lookup = lookupCachedUploadUrl("upload://c.jpeg");
|
||||
@@ -120,47 +120,39 @@ QUnit.test("resolveAllShortUrls", async assert => {
|
||||
lookup = lookupCachedUploadUrl("upload://c.pdf");
|
||||
assert.deepEqual(lookup, {
|
||||
url: "/uploads/default/original/3X/c/b/3.pdf",
|
||||
short_path: "/uploads/short-url/c.pdf"
|
||||
short_path: "/uploads/short-url/c.pdf",
|
||||
});
|
||||
|
||||
lookup = lookupCachedUploadUrl("upload://d.mp4");
|
||||
assert.deepEqual(lookup, {
|
||||
url: "/uploads/default/original/3X/c/b/4.mp4",
|
||||
short_path: "/uploads/short-url/d.mp4"
|
||||
short_path: "/uploads/short-url/d.mp4",
|
||||
});
|
||||
|
||||
lookup = lookupCachedUploadUrl("upload://e.mp3");
|
||||
assert.deepEqual(lookup, {
|
||||
url: "/uploads/default/original/3X/c/b/5.mp3",
|
||||
short_path: "/uploads/short-url/e.mp3"
|
||||
short_path: "/uploads/short-url/e.mp3",
|
||||
});
|
||||
|
||||
lookup = lookupCachedUploadUrl("upload://f.mp4");
|
||||
assert.deepEqual(lookup, {
|
||||
url: "http://localhost:3000/uploads/default/original/3X/c/b/6.mp4",
|
||||
short_path: "/uploads/short-url/f.mp4"
|
||||
short_path: "/uploads/short-url/f.mp4",
|
||||
});
|
||||
});
|
||||
|
||||
QUnit.test(
|
||||
"resolveAllShortUrls - href + src replaced correctly",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
stubUrls();
|
||||
await resolveAllShortUrls(ajax, { secure_media: false }, fixture()[0]);
|
||||
|
||||
let image1 = fixture()
|
||||
.find("img")
|
||||
.eq(0);
|
||||
let image2 = fixture()
|
||||
.find("img")
|
||||
.eq(1);
|
||||
let image1 = fixture().find("img").eq(0);
|
||||
let image2 = fixture().find("img").eq(1);
|
||||
let link = fixture().find("a");
|
||||
let audio = fixture()
|
||||
.find("audio")
|
||||
.eq(0);
|
||||
let video = fixture()
|
||||
.find("video")
|
||||
.eq(0);
|
||||
let audio = fixture().find("audio").eq(0);
|
||||
let video = fixture().find("video").eq(0);
|
||||
|
||||
assert.equal(image1.attr("src"), "/images/avatar.png?a");
|
||||
assert.equal(image2.attr("src"), "/images/avatar.png?b");
|
||||
@@ -178,12 +170,10 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"resolveAllShortUrls - url with full origin replaced correctly",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
stubUrls();
|
||||
await resolveAllShortUrls(ajax, { secure_media: false }, fixture()[0]);
|
||||
let video = fixture()
|
||||
.find("video")
|
||||
.eq(1);
|
||||
let video = fixture().find("video").eq(1);
|
||||
|
||||
assert.equal(
|
||||
video.find("source").attr("src"),
|
||||
@@ -194,15 +184,15 @@ QUnit.test(
|
||||
|
||||
QUnit.test(
|
||||
"resolveAllShortUrls - when secure media is enabled use the attachment full URL",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
stubUrls(
|
||||
null,
|
||||
[
|
||||
{
|
||||
short_url: "upload://c.pdf",
|
||||
url: "/secure-media-uploads/default/original/3X/c/b/3.pdf",
|
||||
short_path: "/uploads/short-url/c.pdf"
|
||||
}
|
||||
short_path: "/uploads/short-url/c.pdf",
|
||||
},
|
||||
],
|
||||
null
|
||||
);
|
||||
@@ -216,7 +206,7 @@ QUnit.test(
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("resolveAllShortUrls - scoped", async assert => {
|
||||
QUnit.test("resolveAllShortUrls - scoped", async (assert) => {
|
||||
stubUrls();
|
||||
let lookup;
|
||||
|
||||
@@ -227,7 +217,7 @@ QUnit.test("resolveAllShortUrls - scoped", async assert => {
|
||||
|
||||
assert.deepEqual(lookup, {
|
||||
url: "/images/avatar.png?z",
|
||||
short_path: "/uploads/short-url/z.jpeg"
|
||||
short_path: "/uploads/short-url/z.jpeg",
|
||||
});
|
||||
|
||||
// do this because the pretender caches ALL the urls, not
|
||||
|
||||
@@ -5,7 +5,7 @@ import {
|
||||
isImage,
|
||||
allowsImages,
|
||||
allowsAttachments,
|
||||
getUploadMarkdown
|
||||
getUploadMarkdown,
|
||||
} from "discourse/lib/uploads";
|
||||
import * as Utilities from "discourse/lib/utilities";
|
||||
import User from "discourse/models/user";
|
||||
@@ -14,7 +14,7 @@ import bootbox from "bootbox";
|
||||
|
||||
discourseModule("lib:uploads");
|
||||
|
||||
QUnit.test("validateUploadedFiles", function(assert) {
|
||||
QUnit.test("validateUploadedFiles", function (assert) {
|
||||
assert.not(
|
||||
validateUploadedFiles(null, { siteSettings: this.siteSettings }),
|
||||
"no files are invalid"
|
||||
@@ -29,7 +29,7 @@ QUnit.test("validateUploadedFiles", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("uploading one file", function(assert) {
|
||||
QUnit.test("uploading one file", function (assert) {
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
assert.not(
|
||||
@@ -38,14 +38,14 @@ QUnit.test("uploading one file", function(assert) {
|
||||
assert.ok(bootbox.alert.calledWith(I18n.t("post.errors.too_many_uploads")));
|
||||
});
|
||||
|
||||
QUnit.test("new user cannot upload images", function(assert) {
|
||||
QUnit.test("new user cannot upload images", function (assert) {
|
||||
this.siteSettings.newuser_max_embedded_media = 0;
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
assert.not(
|
||||
validateUploadedFiles([{ name: "image.png" }], {
|
||||
user: User.create(),
|
||||
siteSettings: this.siteSettings
|
||||
siteSettings: this.siteSettings,
|
||||
}),
|
||||
"the upload is not valid"
|
||||
);
|
||||
@@ -57,7 +57,7 @@ QUnit.test("new user cannot upload images", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("new user can upload images if allowed", function(assert) {
|
||||
QUnit.test("new user can upload images if allowed", function (assert) {
|
||||
this.siteSettings.newuser_max_embedded_media = 1;
|
||||
this.siteSettings.default_trust_level = 0;
|
||||
sandbox.stub(bootbox, "alert");
|
||||
@@ -65,31 +65,31 @@ QUnit.test("new user can upload images if allowed", function(assert) {
|
||||
assert.ok(
|
||||
validateUploadedFiles([{ name: "image.png" }], {
|
||||
user: User.create(),
|
||||
siteSettings: this.siteSettings
|
||||
siteSettings: this.siteSettings,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("TL1 can upload images", function(assert) {
|
||||
QUnit.test("TL1 can upload images", function (assert) {
|
||||
this.siteSettings.newuser_max_embedded_media = 0;
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
assert.ok(
|
||||
validateUploadedFiles([{ name: "image.png" }], {
|
||||
user: User.create({ trust_level: 1 }),
|
||||
siteSettings: this.siteSettings
|
||||
siteSettings: this.siteSettings,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("new user cannot upload attachments", function(assert) {
|
||||
QUnit.test("new user cannot upload attachments", function (assert) {
|
||||
this.siteSettings.newuser_max_attachments = 0;
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
assert.not(
|
||||
validateUploadedFiles([{ name: "roman.txt" }], {
|
||||
user: User.create(),
|
||||
siteSettings: this.siteSettings
|
||||
siteSettings: this.siteSettings,
|
||||
})
|
||||
);
|
||||
assert.ok(
|
||||
@@ -99,41 +99,41 @@ QUnit.test("new user cannot upload attachments", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("ensures an authorized upload", function(assert) {
|
||||
QUnit.test("ensures an authorized upload", function (assert) {
|
||||
sandbox.stub(bootbox, "alert");
|
||||
assert.not(
|
||||
validateUploadedFiles([{ name: "unauthorized.html" }], {
|
||||
siteSettings: this.siteSettings
|
||||
siteSettings: this.siteSettings,
|
||||
})
|
||||
);
|
||||
assert.ok(
|
||||
bootbox.alert.calledWith(
|
||||
I18n.t("post.errors.upload_not_authorized", {
|
||||
authorized_extensions: authorizedExtensions(false, this.siteSettings)
|
||||
authorized_extensions: authorizedExtensions(false, this.siteSettings),
|
||||
})
|
||||
)
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("skipping validation works", function(assert) {
|
||||
QUnit.test("skipping validation works", function (assert) {
|
||||
const files = [{ name: "backup.tar.gz" }];
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
assert.not(
|
||||
validateUploadedFiles(files, {
|
||||
skipValidation: false,
|
||||
siteSettings: this.siteSettings
|
||||
siteSettings: this.siteSettings,
|
||||
})
|
||||
);
|
||||
assert.ok(
|
||||
validateUploadedFiles(files, {
|
||||
skipValidation: true,
|
||||
siteSettings: this.siteSettings
|
||||
siteSettings: this.siteSettings,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("staff can upload anything in PM", function(assert) {
|
||||
QUnit.test("staff can upload anything in PM", function (assert) {
|
||||
const files = [{ name: "some.docx" }];
|
||||
this.siteSettings.authorized_extensions = "jpeg";
|
||||
sandbox.stub(bootbox, "alert");
|
||||
@@ -147,14 +147,14 @@ QUnit.test("staff can upload anything in PM", function(assert) {
|
||||
isPrivateMessage: true,
|
||||
allowStaffToUploadAnyFileInPm: true,
|
||||
siteSettings: this.siteSettings,
|
||||
user
|
||||
user,
|
||||
})
|
||||
);
|
||||
});
|
||||
|
||||
const imageSize = 10 * 1024;
|
||||
|
||||
const dummyBlob = function() {
|
||||
const dummyBlob = function () {
|
||||
const BlobBuilder =
|
||||
window.BlobBuilder ||
|
||||
window.WebKitBlobBuilder ||
|
||||
@@ -169,7 +169,7 @@ const dummyBlob = function() {
|
||||
}
|
||||
};
|
||||
|
||||
QUnit.test("allows valid uploads to go through", function(assert) {
|
||||
QUnit.test("allows valid uploads to go through", function (assert) {
|
||||
sandbox.stub(bootbox, "alert");
|
||||
|
||||
let user = User.create({ trust_level: 1 });
|
||||
@@ -184,15 +184,15 @@ QUnit.test("allows valid uploads to go through", function(assert) {
|
||||
assert.ok(
|
||||
validateUploadedFiles([pastedImage], {
|
||||
user,
|
||||
siteSettings: this.siteSettings
|
||||
siteSettings: this.siteSettings,
|
||||
})
|
||||
);
|
||||
|
||||
assert.not(bootbox.alert.calledOnce);
|
||||
});
|
||||
|
||||
QUnit.test("isImage", assert => {
|
||||
["png", "webp", "jpg", "jpeg", "gif", "ico"].forEach(extension => {
|
||||
QUnit.test("isImage", (assert) => {
|
||||
["png", "webp", "jpg", "jpeg", "gif", "ico"].forEach((extension) => {
|
||||
var image = "image." + extension;
|
||||
assert.ok(isImage(image), image + " is recognized as an image");
|
||||
assert.ok(
|
||||
@@ -205,7 +205,7 @@ QUnit.test("isImage", assert => {
|
||||
assert.not(isImage(""));
|
||||
});
|
||||
|
||||
QUnit.test("allowsImages", function(assert) {
|
||||
QUnit.test("allowsImages", function (assert) {
|
||||
this.siteSettings.authorized_extensions = "jpg|jpeg|gif";
|
||||
assert.ok(allowsImages(false, this.siteSettings), "works");
|
||||
|
||||
@@ -228,7 +228,7 @@ QUnit.test("allowsImages", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("allowsAttachments", function(assert) {
|
||||
QUnit.test("allowsAttachments", function (assert) {
|
||||
this.siteSettings.authorized_extensions = "jpg|jpeg|gif";
|
||||
assert.not(
|
||||
allowsAttachments(false, this.siteSettings),
|
||||
@@ -262,14 +262,14 @@ function testUploadMarkdown(filename, opts = {}) {
|
||||
filesize: 42,
|
||||
thumbnail_width: 100,
|
||||
thumbnail_height: 200,
|
||||
url: "/uploads/123/abcdef.ext"
|
||||
url: "/uploads/123/abcdef.ext",
|
||||
},
|
||||
opts
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
QUnit.test("getUploadMarkdown", assert => {
|
||||
QUnit.test("getUploadMarkdown", (assert) => {
|
||||
assert.equal(
|
||||
testUploadMarkdown("lolcat.gif"),
|
||||
""
|
||||
@@ -298,7 +298,7 @@ QUnit.test("getUploadMarkdown", assert => {
|
||||
|
||||
QUnit.test(
|
||||
"getUploadMarkdown - replaces GUID in image alt text on iOS",
|
||||
assert => {
|
||||
(assert) => {
|
||||
assert.equal(
|
||||
testUploadMarkdown("8F2B469B-6B2C-4213-BC68-57B4876365A0.jpeg"),
|
||||
""
|
||||
|
||||
@@ -5,7 +5,7 @@ import User from "discourse/models/user";
|
||||
|
||||
QUnit.module("lib:url");
|
||||
|
||||
QUnit.test("isInternal with a HTTP url", assert => {
|
||||
QUnit.test("isInternal with a HTTP url", (assert) => {
|
||||
sandbox.stub(DiscourseURL, "origin").returns("http://eviltrout.com");
|
||||
|
||||
assert.not(DiscourseURL.isInternal(null), "a blank URL is not internal");
|
||||
@@ -32,7 +32,7 @@ QUnit.test("isInternal with a HTTP url", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("isInternal with a HTTPS url", assert => {
|
||||
QUnit.test("isInternal with a HTTPS url", (assert) => {
|
||||
sandbox.stub(DiscourseURL, "origin").returns("https://eviltrout.com");
|
||||
assert.ok(
|
||||
DiscourseURL.isInternal("http://eviltrout.com/monocle"),
|
||||
@@ -40,7 +40,7 @@ QUnit.test("isInternal with a HTTPS url", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("isInternal on subfolder install", assert => {
|
||||
QUnit.test("isInternal on subfolder install", (assert) => {
|
||||
sandbox.stub(DiscourseURL, "origin").returns("http://eviltrout.com/forum");
|
||||
assert.not(
|
||||
DiscourseURL.isInternal("http://eviltrout.com"),
|
||||
@@ -56,20 +56,20 @@ QUnit.test("isInternal on subfolder install", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("userPath", assert => {
|
||||
QUnit.test("userPath", (assert) => {
|
||||
assert.equal(userPath(), "/u");
|
||||
assert.equal(userPath("eviltrout"), "/u/eviltrout");
|
||||
assert.equal(userPath("hp.json"), "/u/hp.json");
|
||||
});
|
||||
|
||||
QUnit.test("userPath with prefix", assert => {
|
||||
QUnit.test("userPath with prefix", (assert) => {
|
||||
setPrefix("/forum");
|
||||
assert.equal(userPath(), "/forum/u");
|
||||
assert.equal(userPath("eviltrout"), "/forum/u/eviltrout");
|
||||
assert.equal(userPath("hp.json"), "/forum/u/hp.json");
|
||||
});
|
||||
|
||||
QUnit.test("routeTo with prefix", async assert => {
|
||||
QUnit.test("routeTo with prefix", async (assert) => {
|
||||
setPrefix("/forum");
|
||||
logIn();
|
||||
const user = User.current();
|
||||
|
||||
@@ -4,11 +4,11 @@ import pretender from "helpers/create-pretender";
|
||||
|
||||
QUnit.module("lib:user-search", {
|
||||
beforeEach() {
|
||||
const response = object => {
|
||||
const response = (object) => {
|
||||
return [200, { "Content-Type": "application/json" }, object];
|
||||
};
|
||||
|
||||
pretender.get("/u/search/users", request => {
|
||||
pretender.get("/u/search/users", (request) => {
|
||||
// special responder for per category search
|
||||
const categoryMatch = request.url.match(/category_id=([0-9]+)/);
|
||||
if (categoryMatch) {
|
||||
@@ -21,9 +21,9 @@ QUnit.module("lib:user-search", {
|
||||
username: `category_${categoryMatch[1]}`,
|
||||
name: "category user",
|
||||
avatar_template:
|
||||
"https://avatars.discourse.org/v3/letter/t/41988e/{size}.png"
|
||||
}
|
||||
]
|
||||
"https://avatars.discourse.org/v3/letter/t/41988e/{size}.png",
|
||||
},
|
||||
],
|
||||
});
|
||||
}
|
||||
|
||||
@@ -37,55 +37,55 @@ QUnit.module("lib:user-search", {
|
||||
username: "TeaMoe",
|
||||
name: "TeaMoe",
|
||||
avatar_template:
|
||||
"https://avatars.discourse.org/v3/letter/t/41988e/{size}.png"
|
||||
"https://avatars.discourse.org/v3/letter/t/41988e/{size}.png",
|
||||
},
|
||||
{
|
||||
username: "TeamOneJ",
|
||||
name: "J Cobb",
|
||||
avatar_template:
|
||||
"https://avatars.discourse.org/v3/letter/t/3d9bf3/{size}.png"
|
||||
"https://avatars.discourse.org/v3/letter/t/3d9bf3/{size}.png",
|
||||
},
|
||||
{
|
||||
username: "kudos",
|
||||
name: "Team Blogeto.com",
|
||||
avatar_template:
|
||||
"/user_avatar/meta.discourse.org/kudos/{size}/62185_1.png"
|
||||
"/user_avatar/meta.discourse.org/kudos/{size}/62185_1.png",
|
||||
},
|
||||
{
|
||||
username: "RosieLinda",
|
||||
name: "Linda Teaman",
|
||||
avatar_template:
|
||||
"https://avatars.discourse.org/v3/letter/r/bc8723/{size}.png"
|
||||
"https://avatars.discourse.org/v3/letter/r/bc8723/{size}.png",
|
||||
},
|
||||
{
|
||||
username: "legalatom",
|
||||
name: "Team LegalAtom",
|
||||
avatar_template:
|
||||
"https://avatars.discourse.org/v3/letter/l/a9a28c/{size}.png"
|
||||
"https://avatars.discourse.org/v3/letter/l/a9a28c/{size}.png",
|
||||
},
|
||||
{
|
||||
username: "dzsat_team",
|
||||
name: "Dz Sat Dz Sat",
|
||||
avatar_template:
|
||||
"https://avatars.discourse.org/v3/letter/d/eb9ed0/{size}.png"
|
||||
}
|
||||
"https://avatars.discourse.org/v3/letter/d/eb9ed0/{size}.png",
|
||||
},
|
||||
],
|
||||
groups: [
|
||||
{
|
||||
name: "bob",
|
||||
usernames: []
|
||||
usernames: [],
|
||||
},
|
||||
{
|
||||
name: "team",
|
||||
usernames: []
|
||||
}
|
||||
]
|
||||
usernames: [],
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
QUnit.test("it flushes cache when switching categories", async assert => {
|
||||
QUnit.test("it flushes cache when switching categories", async (assert) => {
|
||||
let results = await userSearch({ term: "hello", categoryId: 1 });
|
||||
assert.equal(results[0].username, "category_1");
|
||||
assert.equal(results.length, 1);
|
||||
@@ -102,7 +102,7 @@ QUnit.test("it flushes cache when switching categories", async assert => {
|
||||
|
||||
QUnit.test(
|
||||
"it returns cancel when eager completing with no results",
|
||||
async assert => {
|
||||
async (assert) => {
|
||||
// Do everything twice, to check the cache works correctly
|
||||
|
||||
for (let i = 0; i < 2; i++) {
|
||||
@@ -126,23 +126,26 @@ QUnit.test(
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("it places groups unconditionally for exact match", async assert => {
|
||||
let results = await userSearch({ term: "Team" });
|
||||
assert.equal(results[results.length - 1]["name"], "team");
|
||||
});
|
||||
QUnit.test(
|
||||
"it places groups unconditionally for exact match",
|
||||
async (assert) => {
|
||||
let results = await userSearch({ term: "Team" });
|
||||
assert.equal(results[results.length - 1]["name"], "team");
|
||||
}
|
||||
);
|
||||
|
||||
QUnit.test("it strips @ from the beginning", async assert => {
|
||||
QUnit.test("it strips @ from the beginning", async (assert) => {
|
||||
let results = await userSearch({ term: "@Team" });
|
||||
assert.equal(results[results.length - 1]["name"], "team");
|
||||
});
|
||||
|
||||
QUnit.test("it skips a search depending on punctuations", async assert => {
|
||||
QUnit.test("it skips a search depending on punctuations", async (assert) => {
|
||||
let results;
|
||||
let skippedTerms = [
|
||||
"@sam s", // double space is not allowed
|
||||
"@sam;",
|
||||
"@sam,",
|
||||
"@sam:"
|
||||
"@sam:",
|
||||
];
|
||||
|
||||
for (let term of skippedTerms) {
|
||||
@@ -155,7 +158,7 @@ QUnit.test("it skips a search depending on punctuations", async assert => {
|
||||
"@sam.sam",
|
||||
"@sam_sam",
|
||||
"@sam-sam",
|
||||
"@"
|
||||
"@",
|
||||
];
|
||||
|
||||
let topicId = 100;
|
||||
@@ -177,7 +180,7 @@ QUnit.test("it skips a search depending on punctuations", async assert => {
|
||||
|
||||
results = await userSearch({
|
||||
term: "no-results@example.com",
|
||||
allowEmails: true
|
||||
allowEmails: true,
|
||||
});
|
||||
assert.equal(results.length, 1);
|
||||
});
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
/* global Int8Array:true */
|
||||
import {
|
||||
escapeExpression,
|
||||
emailValid,
|
||||
@@ -14,14 +13,14 @@ import {
|
||||
toAsciiPrintable,
|
||||
slugify,
|
||||
fillMissingDates,
|
||||
inCodeBlock
|
||||
inCodeBlock,
|
||||
} from "discourse/lib/utilities";
|
||||
import Handlebars from "handlebars";
|
||||
import { discourseModule } from "helpers/qunit-helpers";
|
||||
|
||||
discourseModule("lib:utilities");
|
||||
|
||||
QUnit.test("escapeExpression", assert => {
|
||||
QUnit.test("escapeExpression", (assert) => {
|
||||
assert.equal(escapeExpression(">"), ">", "escapes unsafe characters");
|
||||
|
||||
assert.equal(
|
||||
@@ -37,7 +36,7 @@ QUnit.test("escapeExpression", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("emailValid", assert => {
|
||||
QUnit.test("emailValid", (assert) => {
|
||||
assert.ok(
|
||||
emailValid("Bob@example.com"),
|
||||
"allows upper case in the first part of emails"
|
||||
@@ -48,7 +47,7 @@ QUnit.test("emailValid", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("extractDomainFromUrl", assert => {
|
||||
QUnit.test("extractDomainFromUrl", (assert) => {
|
||||
assert.equal(
|
||||
extractDomainFromUrl("http://meta.discourse.org:443/random"),
|
||||
"meta.discourse.org",
|
||||
@@ -71,7 +70,7 @@ QUnit.test("extractDomainFromUrl", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("avatarUrl", assert => {
|
||||
QUnit.test("avatarUrl", (assert) => {
|
||||
var rawSize = getRawSize;
|
||||
assert.blank(avatarUrl("", "tiny"), "no template returns blank");
|
||||
assert.equal(
|
||||
@@ -86,7 +85,7 @@ QUnit.test("avatarUrl", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
var setDevicePixelRatio = function(value) {
|
||||
var setDevicePixelRatio = function (value) {
|
||||
if (Object.defineProperty && !window.hasOwnProperty("devicePixelRatio")) {
|
||||
Object.defineProperty(window, "devicePixelRatio", { value: 2 });
|
||||
} else {
|
||||
@@ -94,7 +93,7 @@ var setDevicePixelRatio = function(value) {
|
||||
}
|
||||
};
|
||||
|
||||
QUnit.test("avatarImg", assert => {
|
||||
QUnit.test("avatarImg", (assert) => {
|
||||
var oldRatio = window.devicePixelRatio;
|
||||
setDevicePixelRatio(2);
|
||||
|
||||
@@ -109,7 +108,7 @@ QUnit.test("avatarImg", assert => {
|
||||
avatarImg({
|
||||
avatarTemplate: avatarTemplate,
|
||||
size: "tiny",
|
||||
title: "evilest trout"
|
||||
title: "evilest trout",
|
||||
}),
|
||||
"<img alt='' width='20' height='20' src='/path/to/avatar/40.png' class='avatar' title='evilest trout' aria-label='evilest trout'>",
|
||||
"it adds a title if supplied"
|
||||
@@ -119,7 +118,7 @@ QUnit.test("avatarImg", assert => {
|
||||
avatarImg({
|
||||
avatarTemplate: avatarTemplate,
|
||||
size: "tiny",
|
||||
extraClasses: "evil fish"
|
||||
extraClasses: "evil fish",
|
||||
}),
|
||||
"<img alt='' width='20' height='20' src='/path/to/avatar/40.png' class='avatar evil fish'>",
|
||||
"it adds extra classes if supplied"
|
||||
@@ -133,7 +132,7 @@ QUnit.test("avatarImg", assert => {
|
||||
setDevicePixelRatio(oldRatio);
|
||||
});
|
||||
|
||||
QUnit.test("defaultHomepage via meta tag", function(assert) {
|
||||
QUnit.test("defaultHomepage via meta tag", function (assert) {
|
||||
let meta = document.createElement("meta");
|
||||
meta.name = "discourse_current_homepage";
|
||||
meta.content = "hot";
|
||||
@@ -147,7 +146,7 @@ QUnit.test("defaultHomepage via meta tag", function(assert) {
|
||||
document.body.removeChild(meta);
|
||||
});
|
||||
|
||||
QUnit.test("defaultHomepage via site settings", function(assert) {
|
||||
QUnit.test("defaultHomepage via site settings", function (assert) {
|
||||
this.siteSettings.top_menu = "top|latest|hot";
|
||||
initializeDefaultHomepage(this.siteSettings);
|
||||
assert.equal(
|
||||
@@ -157,14 +156,14 @@ QUnit.test("defaultHomepage via site settings", function(assert) {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("setDefaultHomepage", function(assert) {
|
||||
QUnit.test("setDefaultHomepage", function (assert) {
|
||||
initializeDefaultHomepage(this.siteSettings);
|
||||
assert.equal(defaultHomepage(), "latest");
|
||||
setDefaultHomepage("top");
|
||||
assert.equal(defaultHomepage(), "top");
|
||||
});
|
||||
|
||||
QUnit.test("caretRowCol", assert => {
|
||||
QUnit.test("caretRowCol", (assert) => {
|
||||
var textarea = document.createElement("textarea");
|
||||
const content = document.createTextNode("01234\n56789\n012345");
|
||||
textarea.appendChild(content);
|
||||
@@ -195,7 +194,7 @@ QUnit.test("caretRowCol", assert => {
|
||||
document.body.removeChild(textarea);
|
||||
});
|
||||
|
||||
QUnit.test("toAsciiPrintable", assert => {
|
||||
QUnit.test("toAsciiPrintable", (assert) => {
|
||||
const accentedString = "Créme_Brûlée!";
|
||||
const unicodeString = "談話";
|
||||
|
||||
@@ -218,7 +217,7 @@ QUnit.test("toAsciiPrintable", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("slugify", assert => {
|
||||
QUnit.test("slugify", (assert) => {
|
||||
const asciiString = "--- 0__( Some-cool Discourse Site! )__0 --- ";
|
||||
const accentedString = "Créme_Brûlée!";
|
||||
const unicodeString = "談話";
|
||||
@@ -238,7 +237,7 @@ QUnit.test("slugify", assert => {
|
||||
assert.equal(slugify(unicodeString), "", "it removes unicode characters");
|
||||
});
|
||||
|
||||
QUnit.test("fillMissingDates", assert => {
|
||||
QUnit.test("fillMissingDates", (assert) => {
|
||||
const startDate = "2017-11-12"; // YYYY-MM-DD
|
||||
const endDate = "2017-12-12"; // YYYY-MM-DD
|
||||
const data =
|
||||
@@ -251,7 +250,7 @@ QUnit.test("fillMissingDates", assert => {
|
||||
);
|
||||
});
|
||||
|
||||
QUnit.test("inCodeBlock", assert => {
|
||||
QUnit.test("inCodeBlock", (assert) => {
|
||||
const text =
|
||||
"000\n\n```\n111\n```\n\n000\n\n`111 111`\n\n000\n\n[code]\n111\n[/code]\n\n 111\n\t111\n\n000`000";
|
||||
for (let i = 0; i < text.length; ++i) {
|
||||
@@ -263,7 +262,7 @@ QUnit.test("inCodeBlock", assert => {
|
||||
}
|
||||
});
|
||||
|
||||
QUnit.skip("inCodeBlock - runs fast", assert => {
|
||||
QUnit.skip("inCodeBlock - runs fast", (assert) => {
|
||||
const phrase = "Lorem ipsum dolor sit amet, consectetur adipiscing elit.";
|
||||
const text = `${phrase}\n\n\`\`\`\n${phrase}\n\`\`\`\n\n${phrase}\n\n\`${phrase}\n${phrase}\n\n${phrase}\n\n[code]\n${phrase}\n[/code]\n\n${phrase}\n\n ${phrase}\n\n\`${phrase}\`\n\n${phrase}`;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import WhiteLister from "pretty-text/white-lister";
|
||||
|
||||
QUnit.module("lib:whiteLister");
|
||||
|
||||
QUnit.test("whiteLister", assert => {
|
||||
QUnit.test("whiteLister", (assert) => {
|
||||
const whiteLister = new WhiteLister();
|
||||
|
||||
assert.ok(
|
||||
@@ -21,7 +21,7 @@ QUnit.test("whiteLister", assert => {
|
||||
"custom.foo",
|
||||
"custom.baz",
|
||||
"custom[data-*]",
|
||||
"custom[rel=nofollow]"
|
||||
"custom[rel=nofollow]",
|
||||
]);
|
||||
|
||||
whiteLister.whiteListFeature("test", ["custom[rel=test]"]);
|
||||
@@ -32,15 +32,15 @@ QUnit.test("whiteLister", assert => {
|
||||
whiteLister.getWhiteList(),
|
||||
{
|
||||
tagList: {
|
||||
custom: []
|
||||
custom: [],
|
||||
},
|
||||
attrList: {
|
||||
custom: {
|
||||
class: ["foo", "baz"],
|
||||
"data-*": ["*"],
|
||||
rel: ["nofollow", "test"]
|
||||
}
|
||||
}
|
||||
rel: ["nofollow", "test"],
|
||||
},
|
||||
},
|
||||
},
|
||||
"Expecting a correct white list"
|
||||
);
|
||||
@@ -51,7 +51,7 @@ QUnit.test("whiteLister", assert => {
|
||||
whiteLister.getWhiteList(),
|
||||
{
|
||||
tagList: {},
|
||||
attrList: {}
|
||||
attrList: {},
|
||||
},
|
||||
"Expecting an empty white list"
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user