DEV: Use the block form of `module()` (#17151)

This commit is contained in:
Jarek Radosz 2022-06-20 15:42:10 +02:00 committed by GitHub
parent 321118f384
commit ba2c7b8f35
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 713 additions and 709 deletions

View File

@ -1,9 +1,8 @@
import { module, test } from "qunit";
import Theme from "admin/models/theme";
module("Unit | Model | theme");
test("can add an upload correctly", function (assert) {
module("Unit | Model | theme", function () {
test("can add an upload correctly", function (assert) {
let theme = Theme.create();
assert.strictEqual(
@ -15,8 +14,13 @@ test("can add an upload correctly", function (assert) {
theme.setField("common", "bob", "", 999, 2);
let fields = theme.get("theme_fields");
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(theme.get("uploads.length"), 1, "expecting an upload");
});
});

View File

@ -1,8 +1,6 @@
import PrettyText, { buildOptions } from "pretty-text/pretty-text";
import { module, test } from "qunit";
module("lib:details-cooked-test");
const defaultOpts = buildOptions({
siteSettings: {
enable_emoji: true,
@ -14,7 +12,8 @@ const defaultOpts = buildOptions({
getURL: (url) => url,
});
test("details", function (assert) {
module("lib:details-cooked-test", function () {
test("details", function (assert) {
const cooked = (input, expected, text) => {
assert.strictEqual(
new PrettyText(defaultOpts).cook(input),
@ -36,4 +35,5 @@ testing</summary>
<p>test</p>
</details>`
);
});
});

View File

@ -4,8 +4,6 @@ import { module, test } from "qunit";
const PARIS = "Europe/Paris";
const SYDNEY = "Australia/Sydney";
module("lib:date-with-zone-helper");
function buildDateHelper(params = {}) {
return new DateWithZoneHelper({
year: params.year || 2020,
@ -18,7 +16,8 @@ function buildDateHelper(params = {}) {
});
}
test("#format", function (assert) {
module("lib:date-with-zone-helper", function () {
test("#format", function (assert) {
let date = buildDateHelper({
day: 15,
month: 2,
@ -27,9 +26,9 @@ test("#format", function (assert) {
timezone: PARIS,
});
assert.strictEqual(date.format(), "2020-03-15T15:36:00.000+01:00");
});
});
test("#unitRepetitionsBetweenDates", function (assert) {
test("#unitRepetitionsBetweenDates", function (assert) {
let date;
date = buildDateHelper({
@ -95,9 +94,9 @@ test("#unitRepetitionsBetweenDates", function (assert) {
6,
"it correctly finds difference with a multiplicator"
);
});
});
test("#add", function (assert) {
test("#add", function (assert) {
let date;
let futureLocalDate;
@ -166,4 +165,5 @@ test("#add", function (assert) {
"2020-12-01T15:36:00.000+01:00",
"it correctly adds from a isDST date to a !isDST date"
);
});
});

View File

@ -11,8 +11,6 @@ const PARIS = "Europe/Paris";
const LAGOS = "Africa/Lagos";
const LONDON = "Europe/London";
module("lib:local-date-builder");
function freezeTime({ date, timezone }, cb) {
date = date || "2020-01-22 10:34";
const newTimezone = timezone || PARIS;
@ -50,7 +48,7 @@ QUnit.assert.buildsCorrectDate = function (options, expected, message) {
this.test.assert.strictEqual(
localDateBuilder.build().formated,
expected.formated,
message || "it formates the date correctly"
message || "it formats the date correctly"
);
}
@ -58,12 +56,13 @@ QUnit.assert.buildsCorrectDate = function (options, expected, message) {
this.test.assert.deepEqual(
localDateBuilder.build().previews,
expected.previews,
message || "it formates the previews correctly"
message || "it formats the previews correctly"
);
}
};
test("date", function (assert) {
module("lib:local-date-builder", function () {
test("date", function (assert) {
freezeTime({ date: "2020-03-11" }, () => {
assert.buildsCorrectDate(
{ date: "2020-03-22", timezone: PARIS },
@ -71,9 +70,9 @@ test("date", function (assert) {
"it displays the date without time"
);
});
});
});
test("date and time", function (assert) {
test("date and time", function (assert) {
assert.buildsCorrectDate(
{ date: "2020-04-11", time: "11:00" },
{ formated: "April 11, 2020 1:00 PM" },
@ -85,9 +84,9 @@ test("date and time", function (assert) {
{ formated: "1:05:12 PM" },
"it displays full time (hours, minutes, seconds)"
);
});
});
test("option[format]", function (assert) {
test("option[format]", function (assert) {
freezeTime({ date: "2020-03-11" }, () => {
assert.buildsCorrectDate(
{ format: "YYYY" },
@ -95,9 +94,9 @@ test("option[format]", function (assert) {
"it uses custom format"
);
});
});
});
test("option[displayedTimezone]", function (assert) {
test("option[displayedTimezone]", function (assert) {
freezeTime({}, () => {
assert.buildsCorrectDate(
{ displayedTimezone: SYDNEY },
@ -129,9 +128,9 @@ test("option[displayedTimezone]", function (assert) {
"it removes prefix and replaces `_`"
);
});
});
});
test("option[timezone]", function (assert) {
test("option[timezone]", function (assert) {
freezeTime({}, () => {
assert.buildsCorrectDate(
{ timezone: SYDNEY, displayedTimezone: PARIS },
@ -139,9 +138,9 @@ test("option[timezone]", function (assert) {
"it correctly parses a date with the given timezone context"
);
});
});
});
test("option[recurring]", function (assert) {
test("option[recurring]", function (assert) {
freezeTime({ date: "2020-04-06 06:00", timezone: LAGOS }, () => {
assert.buildsCorrectDate(
{
@ -249,9 +248,9 @@ test("option[recurring]", function (assert) {
"it works with hours"
);
});
});
});
test("option[countown]", function (assert) {
test("option[countdown]", function (assert) {
freezeTime({ date: "2020-03-21 23:59" }, () => {
assert.buildsCorrectDate(
{
@ -277,9 +276,9 @@ test("option[countown]", function (assert) {
"it shows the date has passed"
);
});
});
});
test("option[calendar]", function (assert) {
test("option[calendar]", function (assert) {
freezeTime({ date: "2020-03-23 23:00" }, () => {
assert.buildsCorrectDate(
{ date: "2020-03-22", time: "23:59", timezone: PARIS },
@ -343,7 +342,7 @@ test("option[calendar]", function (assert) {
assert.buildsCorrectDate(
{ date: "2020-03-21", timezone: PARIS },
{ formated: "March 21, 2020" },
"it stops formating out of calendar range"
"it stops formatting out of calendar range"
)
);
@ -358,9 +357,9 @@ test("option[calendar]", function (assert) {
"it correctly displays a different local timezone"
);
});
});
});
test("previews", function (assert) {
test("previews", function (assert) {
freezeTime({ date: "2020-03-22" }, () => {
assert.buildsCorrectDate(
{ timezone: PARIS },
@ -416,7 +415,7 @@ test("previews", function (assert) {
freezeTime({ date: "2020-03-22", timezone: PARIS }, () => {
assert.buildsCorrectDate(
{ timezone: PARIS, isplayedTimezone: PARIS },
{ timezone: PARIS, displayedTimezone: PARIS },
{
previews: [
{
@ -589,4 +588,5 @@ test("previews", function (assert) {
}
);
});
});
});