mirror of
https://github.com/discourse/discourse.git
synced 2025-02-22 20:04:25 +08:00
DEV: Use the block form of module()
(#17151)
This commit is contained in:
parent
321118f384
commit
ba2c7b8f35
@ -1,8 +1,7 @@
|
|||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import Theme from "admin/models/theme";
|
import Theme from "admin/models/theme";
|
||||||
|
|
||||||
module("Unit | Model | theme");
|
module("Unit | Model | theme", function () {
|
||||||
|
|
||||||
test("can add an upload correctly", function (assert) {
|
test("can add an upload correctly", function (assert) {
|
||||||
let theme = Theme.create();
|
let theme = Theme.create();
|
||||||
|
|
||||||
@ -15,8 +14,13 @@ test("can add an upload correctly", function (assert) {
|
|||||||
theme.setField("common", "bob", "", 999, 2);
|
theme.setField("common", "bob", "", 999, 2);
|
||||||
let fields = theme.get("theme_fields");
|
let fields = theme.get("theme_fields");
|
||||||
assert.strictEqual(fields.length, 1, "expecting 1 theme field");
|
assert.strictEqual(fields.length, 1, "expecting 1 theme field");
|
||||||
assert.strictEqual(fields[0].upload_id, 999, "expecting upload id to be set");
|
assert.strictEqual(
|
||||||
|
fields[0].upload_id,
|
||||||
|
999,
|
||||||
|
"expecting upload id to be set"
|
||||||
|
);
|
||||||
assert.strictEqual(fields[0].type_id, 2, "expecting type id to be set");
|
assert.strictEqual(fields[0].type_id, 2, "expecting type id to be set");
|
||||||
|
|
||||||
assert.strictEqual(theme.get("uploads.length"), 1, "expecting an upload");
|
assert.strictEqual(theme.get("uploads.length"), 1, "expecting an upload");
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
@ -1,8 +1,6 @@
|
|||||||
import PrettyText, { buildOptions } from "pretty-text/pretty-text";
|
import PrettyText, { buildOptions } from "pretty-text/pretty-text";
|
||||||
import { module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
|
|
||||||
module("lib:details-cooked-test");
|
|
||||||
|
|
||||||
const defaultOpts = buildOptions({
|
const defaultOpts = buildOptions({
|
||||||
siteSettings: {
|
siteSettings: {
|
||||||
enable_emoji: true,
|
enable_emoji: true,
|
||||||
@ -14,6 +12,7 @@ const defaultOpts = buildOptions({
|
|||||||
getURL: (url) => url,
|
getURL: (url) => url,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
module("lib:details-cooked-test", function () {
|
||||||
test("details", function (assert) {
|
test("details", function (assert) {
|
||||||
const cooked = (input, expected, text) => {
|
const cooked = (input, expected, text) => {
|
||||||
assert.strictEqual(
|
assert.strictEqual(
|
||||||
@ -37,3 +36,4 @@ testing</summary>
|
|||||||
</details>`
|
</details>`
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
@ -4,8 +4,6 @@ import { module, test } from "qunit";
|
|||||||
const PARIS = "Europe/Paris";
|
const PARIS = "Europe/Paris";
|
||||||
const SYDNEY = "Australia/Sydney";
|
const SYDNEY = "Australia/Sydney";
|
||||||
|
|
||||||
module("lib:date-with-zone-helper");
|
|
||||||
|
|
||||||
function buildDateHelper(params = {}) {
|
function buildDateHelper(params = {}) {
|
||||||
return new DateWithZoneHelper({
|
return new DateWithZoneHelper({
|
||||||
year: params.year || 2020,
|
year: params.year || 2020,
|
||||||
@ -18,6 +16,7 @@ function buildDateHelper(params = {}) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
module("lib:date-with-zone-helper", function () {
|
||||||
test("#format", function (assert) {
|
test("#format", function (assert) {
|
||||||
let date = buildDateHelper({
|
let date = buildDateHelper({
|
||||||
day: 15,
|
day: 15,
|
||||||
@ -167,3 +166,4 @@ test("#add", function (assert) {
|
|||||||
"it correctly adds from a isDST date to a !isDST date"
|
"it correctly adds from a isDST date to a !isDST date"
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
@ -11,8 +11,6 @@ const PARIS = "Europe/Paris";
|
|||||||
const LAGOS = "Africa/Lagos";
|
const LAGOS = "Africa/Lagos";
|
||||||
const LONDON = "Europe/London";
|
const LONDON = "Europe/London";
|
||||||
|
|
||||||
module("lib:local-date-builder");
|
|
||||||
|
|
||||||
function freezeTime({ date, timezone }, cb) {
|
function freezeTime({ date, timezone }, cb) {
|
||||||
date = date || "2020-01-22 10:34";
|
date = date || "2020-01-22 10:34";
|
||||||
const newTimezone = timezone || PARIS;
|
const newTimezone = timezone || PARIS;
|
||||||
@ -50,7 +48,7 @@ QUnit.assert.buildsCorrectDate = function (options, expected, message) {
|
|||||||
this.test.assert.strictEqual(
|
this.test.assert.strictEqual(
|
||||||
localDateBuilder.build().formated,
|
localDateBuilder.build().formated,
|
||||||
expected.formated,
|
expected.formated,
|
||||||
message || "it formates the date correctly"
|
message || "it formats the date correctly"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -58,11 +56,12 @@ QUnit.assert.buildsCorrectDate = function (options, expected, message) {
|
|||||||
this.test.assert.deepEqual(
|
this.test.assert.deepEqual(
|
||||||
localDateBuilder.build().previews,
|
localDateBuilder.build().previews,
|
||||||
expected.previews,
|
expected.previews,
|
||||||
message || "it formates the previews correctly"
|
message || "it formats the previews correctly"
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
module("lib:local-date-builder", function () {
|
||||||
test("date", function (assert) {
|
test("date", function (assert) {
|
||||||
freezeTime({ date: "2020-03-11" }, () => {
|
freezeTime({ date: "2020-03-11" }, () => {
|
||||||
assert.buildsCorrectDate(
|
assert.buildsCorrectDate(
|
||||||
@ -251,7 +250,7 @@ test("option[recurring]", function (assert) {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
test("option[countown]", function (assert) {
|
test("option[countdown]", function (assert) {
|
||||||
freezeTime({ date: "2020-03-21 23:59" }, () => {
|
freezeTime({ date: "2020-03-21 23:59" }, () => {
|
||||||
assert.buildsCorrectDate(
|
assert.buildsCorrectDate(
|
||||||
{
|
{
|
||||||
@ -343,7 +342,7 @@ test("option[calendar]", function (assert) {
|
|||||||
assert.buildsCorrectDate(
|
assert.buildsCorrectDate(
|
||||||
{ date: "2020-03-21", timezone: PARIS },
|
{ date: "2020-03-21", timezone: PARIS },
|
||||||
{ formated: "March 21, 2020" },
|
{ formated: "March 21, 2020" },
|
||||||
"it stops formating out of calendar range"
|
"it stops formatting out of calendar range"
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -416,7 +415,7 @@ test("previews", function (assert) {
|
|||||||
|
|
||||||
freezeTime({ date: "2020-03-22", timezone: PARIS }, () => {
|
freezeTime({ date: "2020-03-22", timezone: PARIS }, () => {
|
||||||
assert.buildsCorrectDate(
|
assert.buildsCorrectDate(
|
||||||
{ timezone: PARIS, isplayedTimezone: PARIS },
|
{ timezone: PARIS, displayedTimezone: PARIS },
|
||||||
{
|
{
|
||||||
previews: [
|
previews: [
|
||||||
{
|
{
|
||||||
@ -590,3 +589,4 @@ test("previews", function (assert) {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
Loading…
x
Reference in New Issue
Block a user