DEV: Use `test`-provided `assert` object (#29794)
This commit is contained in:
parent
93983286b5
commit
6e68de79d2
|
@ -1,12 +1,12 @@
|
||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import { assert, module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
|
|
||||||
module("Addons | truth-helpers | Integration | includes", function (hooks) {
|
module("Addons | truth-helpers | Integration | includes", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("when using an array", async function () {
|
test("when using an array", async function (assert) {
|
||||||
this.foo = [1];
|
this.foo = [1];
|
||||||
this.bar = 1;
|
this.bar = 1;
|
||||||
await render(
|
await render(
|
||||||
|
@ -23,7 +23,7 @@ module("Addons | truth-helpers | Integration | includes", function (hooks) {
|
||||||
assert.dom(".test").doesNotExist("is false when element is not found");
|
assert.dom(".test").doesNotExist("is false when element is not found");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("when using a string", async function () {
|
test("when using a string", async function (assert) {
|
||||||
this.foo = "foo";
|
this.foo = "foo";
|
||||||
this.bar = "f";
|
this.bar = "f";
|
||||||
await render(
|
await render(
|
||||||
|
|
|
@ -2,7 +2,7 @@ import Component from "@glimmer/component";
|
||||||
import { setComponentTemplate } from "@glimmer/manager";
|
import { setComponentTemplate } from "@glimmer/manager";
|
||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import { assert, module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import sinon from "sinon";
|
import sinon from "sinon";
|
||||||
import { overrideThrowGjsError } from "discourse/instance-initializers/component-templates";
|
import { overrideThrowGjsError } from "discourse/instance-initializers/component-templates";
|
||||||
import { forceMobile } from "discourse/lib/mobile";
|
import { forceMobile } from "discourse/lib/mobile";
|
||||||
|
@ -122,14 +122,14 @@ module("Integration | Initializers | plugin-component-templates", function (h) {
|
||||||
hooks.beforeEach(() => registerTemplateOnlyComponents());
|
hooks.beforeEach(() => registerTemplateOnlyComponents());
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("treats plugin template-only definition as classic component", async function () {
|
test("treats plugin template-only definition as classic component", async function (assert) {
|
||||||
await render(hbs`<PluginTemplateOnlyDefinition class='test-class'/>`);
|
await render(hbs`<PluginTemplateOnlyDefinition class='test-class'/>`);
|
||||||
assert
|
assert
|
||||||
.dom("div.test-class")
|
.dom("div.test-class")
|
||||||
.hasText("classic component", "renders as classic component");
|
.hasText("classic component", "renders as classic component");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("leaves core template-only definition as glimmer template-only component", async function () {
|
test("leaves core template-only definition as glimmer template-only component", async function (assert) {
|
||||||
await render(hbs`<CoreTemplateOnlyDefinition class='test-class'/>`);
|
await render(hbs`<CoreTemplateOnlyDefinition class='test-class'/>`);
|
||||||
assert
|
assert
|
||||||
.dom("div.test-class")
|
.dom("div.test-class")
|
||||||
|
@ -142,7 +142,7 @@ module("Integration | Initializers | plugin-component-templates", function (h) {
|
||||||
hooks.beforeEach(() => registerBaseComponents());
|
hooks.beforeEach(() => registerBaseComponents());
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("renders core templates when there are no overrides", async function () {
|
test("renders core templates when there are no overrides", async function (assert) {
|
||||||
await render(TestTemplate);
|
await render(TestTemplate);
|
||||||
assert
|
assert
|
||||||
.dom("#mock-colocated")
|
.dom("#mock-colocated")
|
||||||
|
@ -161,7 +161,7 @@ module("Integration | Initializers | plugin-component-templates", function (h) {
|
||||||
|
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("core mobile overrides are used", async function () {
|
test("core mobile overrides are used", async function (assert) {
|
||||||
await render(TestTemplate);
|
await render(TestTemplate);
|
||||||
assert
|
assert
|
||||||
.dom("#mock-colocated")
|
.dom("#mock-colocated")
|
||||||
|
@ -177,7 +177,7 @@ module("Integration | Initializers | plugin-component-templates", function (h) {
|
||||||
hooks.beforeEach(registerThemeOverrides);
|
hooks.beforeEach(registerThemeOverrides);
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("theme overrides are used", async function () {
|
test("theme overrides are used", async function (assert) {
|
||||||
await render(TestTemplate);
|
await render(TestTemplate);
|
||||||
assert
|
assert
|
||||||
.dom("#mock-colocated")
|
.dom("#mock-colocated")
|
||||||
|
@ -197,7 +197,7 @@ module("Integration | Initializers | plugin-component-templates", function (h) {
|
||||||
|
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("mobile theme overrides are used", async function () {
|
test("mobile theme overrides are used", async function (assert) {
|
||||||
await render(TestTemplate);
|
await render(TestTemplate);
|
||||||
assert
|
assert
|
||||||
.dom("#mock-colocated")
|
.dom("#mock-colocated")
|
||||||
|
@ -219,7 +219,7 @@ module("Integration | Initializers | plugin-component-templates", function (h) {
|
||||||
hooks.beforeEach(registerPluginOverrides);
|
hooks.beforeEach(registerPluginOverrides);
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("plugin overrides are used", async function () {
|
test("plugin overrides are used", async function (assert) {
|
||||||
await render(TestTemplate);
|
await render(TestTemplate);
|
||||||
assert
|
assert
|
||||||
.dom("#mock-colocated")
|
.dom("#mock-colocated")
|
||||||
|
@ -236,7 +236,7 @@ module("Integration | Initializers | plugin-component-templates", function (h) {
|
||||||
hooks.beforeEach(registerThemeOverrides);
|
hooks.beforeEach(registerThemeOverrides);
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("plugin overrides are used", async function () {
|
test("plugin overrides are used", async function (assert) {
|
||||||
await render(TestTemplate);
|
await render(TestTemplate);
|
||||||
assert
|
assert
|
||||||
.dom("#mock-colocated")
|
.dom("#mock-colocated")
|
||||||
|
@ -253,7 +253,7 @@ module("Integration | Initializers | plugin-component-templates", function (h) {
|
||||||
hooks.beforeEach(registerOtherPluginOverrides);
|
hooks.beforeEach(registerOtherPluginOverrides);
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("last-defined plugin overrides are used", async function () {
|
test("last-defined plugin overrides are used", async function (assert) {
|
||||||
await render(TestTemplate);
|
await render(TestTemplate);
|
||||||
assert
|
assert
|
||||||
.dom("#mock-colocated")
|
.dom("#mock-colocated")
|
||||||
|
@ -277,7 +277,7 @@ module("Integration | Initializers | plugin-component-templates", function (h) {
|
||||||
hooks.beforeEach(registerThemeOverrides);
|
hooks.beforeEach(registerThemeOverrides);
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("theme overrides plugin component", async function () {
|
test("theme overrides plugin component", async function (assert) {
|
||||||
await render(TestTemplate);
|
await render(TestTemplate);
|
||||||
assert
|
assert
|
||||||
.dom("#mock-colocated")
|
.dom("#mock-colocated")
|
||||||
|
@ -319,7 +319,7 @@ module("Integration | Initializers | plugin-component-templates", function (h) {
|
||||||
|
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("theme overrides plugin component", async function () {
|
test("theme overrides plugin component", async function (assert) {
|
||||||
await render(hbs`<MockGjsComponent />`);
|
await render(hbs`<MockGjsComponent />`);
|
||||||
assert
|
assert
|
||||||
.dom(".greeting")
|
.dom(".greeting")
|
||||||
|
|
|
@ -1,18 +1,18 @@
|
||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import { assert, module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
|
|
||||||
module("Integration | Helper | category-link", function (hooks) {
|
module("Integration | Helper | category-link", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("name", async function () {
|
test("name", async function (assert) {
|
||||||
await render(hbs`{{category-link (hash name="foo")}}`);
|
await render(hbs`{{category-link (hash name="foo")}}`);
|
||||||
|
|
||||||
assert.dom(".badge-category__name").hasText("foo");
|
assert.dom(".badge-category__name").hasText("foo");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("description_text", async function () {
|
test("description_text", async function (assert) {
|
||||||
await render(
|
await render(
|
||||||
hbs`{{category-link (hash name="foo" description_text="bar")}}`
|
hbs`{{category-link (hash name="foo" description_text="bar")}}`
|
||||||
);
|
);
|
||||||
|
|
|
@ -1,39 +1,39 @@
|
||||||
import { render } from "@ember/test-helpers";
|
import { render } from "@ember/test-helpers";
|
||||||
import { hbs } from "ember-cli-htmlbars";
|
import { hbs } from "ember-cli-htmlbars";
|
||||||
import { assert, module, test } from "qunit";
|
import { module, test } from "qunit";
|
||||||
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
|
||||||
|
|
||||||
module("Integration | Helper | concat-class", function (hooks) {
|
module("Integration | Helper | concat-class", function (hooks) {
|
||||||
setupRenderingTest(hooks);
|
setupRenderingTest(hooks);
|
||||||
|
|
||||||
test("One class given", async function () {
|
test("One class given", async function (assert) {
|
||||||
await render(hbs`<button class={{concat-class "foo"}} />`);
|
await render(hbs`<button class={{concat-class "foo"}} />`);
|
||||||
|
|
||||||
assert.dom("button").hasAttribute("class", "foo");
|
assert.dom("button").hasAttribute("class", "foo");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Multiple class given", async function () {
|
test("Multiple class given", async function (assert) {
|
||||||
this.set("bar", "bar");
|
this.set("bar", "bar");
|
||||||
await render(hbs`<button class={{concat-class "foo" this.bar}} />`);
|
await render(hbs`<button class={{concat-class "foo" this.bar}} />`);
|
||||||
|
|
||||||
assert.dom("button").hasAttribute("class", "foo bar");
|
assert.dom("button").hasAttribute("class", "foo bar");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("One undefined class given", async function () {
|
test("One undefined class given", async function (assert) {
|
||||||
this.set("bar", null);
|
this.set("bar", null);
|
||||||
await render(hbs`<button class={{concat-class "foo" this.bar}} />`);
|
await render(hbs`<button class={{concat-class "foo" this.bar}} />`);
|
||||||
|
|
||||||
assert.dom("button").hasAttribute("class", "foo");
|
assert.dom("button").hasAttribute("class", "foo");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Only undefined class given", async function () {
|
test("Only undefined class given", async function (assert) {
|
||||||
this.set("bar", null);
|
this.set("bar", null);
|
||||||
await render(hbs`<button class={{concat-class null this.bar}} />`);
|
await render(hbs`<button class={{concat-class null this.bar}} />`);
|
||||||
|
|
||||||
assert.dom("button").doesNotHaveAttribute("class");
|
assert.dom("button").doesNotHaveAttribute("class");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Helpers used", async function () {
|
test("Helpers used", async function (assert) {
|
||||||
await render(
|
await render(
|
||||||
hbs`<button class={{concat-class (if true "foo") (if true "bar")}} />`
|
hbs`<button class={{concat-class (if true "foo") (if true "bar")}} />`
|
||||||
);
|
);
|
||||||
|
@ -41,7 +41,7 @@ module("Integration | Helper | concat-class", function (hooks) {
|
||||||
assert.dom("button").hasAttribute("class", "foo bar");
|
assert.dom("button").hasAttribute("class", "foo bar");
|
||||||
});
|
});
|
||||||
|
|
||||||
test("Arrays", async function () {
|
test("Arrays", async function (assert) {
|
||||||
await render(
|
await render(
|
||||||
hbs`<button class={{concat-class (array) (array "foo" "bar") (array null)}} />`
|
hbs`<button class={{concat-class (array) (array "foo" "bar") (array null)}} />`
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue