Skip to content

Commit

Permalink
updates to qunit best practices
Browse files Browse the repository at this point in the history
  • Loading branch information
brrusselburg committed Dec 6, 2024
1 parent 6a57ab5 commit bd202d9
Showing 1 changed file with 57 additions and 49 deletions.
106 changes: 57 additions & 49 deletions test/javascripts/integration/components/upcoming-events-list-test.gjs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,21 @@ module("Integration | Component | upcoming-events-list", function (hooks) {

this.appEvents.trigger("page:changed", { url: "/" });

assert.strictEqual(
query(".upcoming-events-list__heading").innerText,
I18n.t("discourse_post_event.upcoming_events_list.title"),
"it displays the title"
);
assert
.dom(".upcoming-events-list__heading")
.hasText(
I18n.t("discourse_post_event.upcoming_events_list.title"),
"it displays the title"
);

await waitFor(".loading-container .spinner", { count: 0 });

assert.strictEqual(
query(".upcoming-events-list__empty-message").innerText,
I18n.t("discourse_post_event.upcoming_events_list.empty"),
"it displays the empty list message"
);
assert
.dom(".upcoming-events-list__empty-message")
.hasText(
I18n.t("discourse_post_event.upcoming_events_list.empty"),
"it displays the empty list message"
);
});

test("with events", async function (assert) {
Expand All @@ -78,11 +80,12 @@ module("Integration | Component | upcoming-events-list", function (hooks) {

this.appEvents.trigger("page:changed", { url: "/" });

assert.strictEqual(
query(".upcoming-events-list__heading").innerText,
I18n.t("discourse_post_event.upcoming_events_list.title"),
"it displays the title"
);
assert
.dom(".upcoming-events-list__heading")
.hasText(
I18n.t("discourse_post_event.upcoming_events_list.title"),
"it displays the title"
);

await waitFor(".loading-container .spinner", { count: 0 });

Expand Down Expand Up @@ -124,10 +127,9 @@ module("Integration | Component | upcoming-events-list", function (hooks) {
"it displays the event name"
);

assert.ok(
exists(".upcoming-events-list__view-all"),
"it displays the view-all link"
);
assert
.dom(".upcoming-events-list__view-all")
.exists("it displays the view-all link");
});

test("with multi-day events, standard formats", async function (assert) {
Expand Down Expand Up @@ -204,11 +206,12 @@ module("Integration | Component | upcoming-events-list", function (hooks) {

await waitFor(".loading-container .spinner", { count: 0 });

assert.strictEqual(
query(".upcoming-events-list__view-all").innerText,
I18n.t("discourse_post_event.upcoming_events_list.view_all"),
"it displays the view-all link"
);
assert
.dom(".upcoming-events-list__view-all")
.hasText(
I18n.t("discourse_post_event.upcoming_events_list.view_all"),
"it displays the view-all link"
);

await click(".upcoming-events-list__view-all");

Expand All @@ -228,11 +231,12 @@ module("Integration | Component | upcoming-events-list", function (hooks) {

this.appEvents.trigger("page:changed", { url: "/" });

assert.strictEqual(
query(".upcoming-events-list__heading").innerText,
I18n.t("discourse_post_event.upcoming_events_list.title"),
"it displays the title"
);
assert
.dom(".upcoming-events-list__heading")
.hasText(
I18n.t("discourse_post_event.upcoming_events_list.title"),
"it displays the title"
);

await waitFor(".loading-container .spinner", { count: 0 });

Expand Down Expand Up @@ -265,25 +269,28 @@ module("Integration | Component | upcoming-events-list", function (hooks) {

this.appEvents.trigger("page:changed", { url: "/" });

assert.strictEqual(
query(".upcoming-events-list__heading").innerText,
I18n.t("discourse_post_event.upcoming_events_list.title"),
"it displays the title"
);
assert
.dom(".upcoming-events-list__heading")
.hasText(
I18n.t("discourse_post_event.upcoming_events_list.title"),
"it displays the title"
);

await waitFor(".loading-container .spinner", { count: 0 });

assert.strictEqual(
query(".upcoming-events-list__error-message").innerText,
I18n.t("discourse_post_event.upcoming_events_list.error"),
"it displays the error message"
);
assert
.dom(".upcoming-events-list__error-message")
.hasText(
I18n.t("discourse_post_event.upcoming_events_list.error"),
"it displays the error message"
);

assert.strictEqual(
query(".upcoming-events-list__try-again").innerText,
I18n.t("discourse_post_event.upcoming_events_list.try_again"),
"it displays the try again button"
);
assert
.dom(".upcoming-events-list__try-again")
.hasText(
I18n.t("discourse_post_event.upcoming_events_list.try_again"),
"it displays the try again button"
);
});

test("with events, overridden count parameter", async function (assert) {
Expand All @@ -295,11 +302,12 @@ module("Integration | Component | upcoming-events-list", function (hooks) {

this.appEvents.trigger("page:changed", { url: "/" });

assert.strictEqual(
query(".upcoming-events-list__heading").innerText,
I18n.t("discourse_post_event.upcoming_events_list.title"),
"it displays the title"
);
assert
.dom(".upcoming-events-list__heading")
.hasText(
I18n.t("discourse_post_event.upcoming_events_list.title"),
"it displays the title"
);

await waitFor(".loading-container .spinner", { count: 0 });

Expand Down

0 comments on commit bd202d9

Please sign in to comment.