discourse/plugins/discourse-calendar/test/javascripts/integration/components/admin-holidays-list-item-test.gjs
David Taylor 9322a46fa4
DEV: Remove unneeded const self = this; from qunit tests (#35632)
This was required in older versions of Ember. But now, bare template
tags can access `this.`. This commit was created by upgrading lint-configs, and then running 
`pnpm lint:js:fix && pnpm lint:prettier:fix`

Rule development: https://github.com/discourse/lint-configs/pull/154
2025-10-27 18:07:22 +00:00

57 lines
1.8 KiB
Text
Vendored

import { render } from "@ember/test-helpers";
import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import AdminHolidaysListItem from "discourse/plugins/discourse-calendar/discourse/components/admin-holidays-list-item";
module("Integration | Component | AdminHolidaysListItem", function (hooks) {
setupRenderingTest(hooks);
test("when a holiday is disabled, it displays an enable button and adds a disabled CSS class", async function (assert) {
this.set("holiday", {
date: "2022-01-01",
name: "New Year's Day",
disabled: true,
});
this.set("region_code", "sg");
await render(
<template>
<AdminHolidaysListItem
@holiday={{this.holiday}}
@region_code={{this.region_code}}
@isHolidayDisabled={{this.holiday.disabled}}
/>
</template>
);
assert.dom("button").hasText("Enable", "it displays an enable button");
assert.dom("tr").hasClass("--disabled", "it adds a '--disabled' CSS class");
});
test("when a holiday is enabled, it displays a disable button and does not add a disabled CSS class", async function (assert) {
this.set("holiday", {
date: "2022-01-01",
name: "New Year's Day",
disabled: false,
});
this.set("region_code", "au");
await render(
<template>
<AdminHolidaysListItem
@holiday={{this.holiday}}
@region_code={{this.region_code}}
@isHolidayDisabled={{this.holiday.disabled}}
/>
</template>
);
assert.dom("button").hasText("Disable", "it displays a disable button");
assert
.dom("tr")
.doesNotHaveClass(
"--disabled",
"it does not add a '--disabled' CSS class"
);
});
});