This repository has been archived on 2023-03-18. You can view files and clone it, but cannot push or open issues or pull requests.
osr-discourse-src/app/assets/javascripts/discourse/tests/integration/components/select-kit/pinned-options-test.js
2022-11-03 12:32:20 +01:00

64 lines
1.8 KiB
JavaScript

import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { render } from "@ember/test-helpers";
import { hbs } from "ember-cli-htmlbars";
import selectKit from "discourse/tests/helpers/select-kit-helper";
import { getOwner } from "discourse-common/lib/get-owner";
module("Integration | Component | select-kit/pinned-options", function (hooks) {
setupRenderingTest(hooks);
test("unpinning", async function (assert) {
this.siteSettings.automatically_unpin_topics = false;
this.set("subject", selectKit());
const store = getOwner(this).lookup("service:store");
this.set(
"topic",
store.createRecord("topic", {
id: 1234,
title: "Qunit Test Topic",
deleted_at: new Date(),
pinned: true,
})
);
await render(
hbs`<PinnedOptions @value={{this.topic.pinned}} @topic={{this.topic}} />`
);
assert.strictEqual(this.subject.header().name(), "pinned");
await this.subject.expand();
await this.subject.selectRowByValue("unpinned");
assert.strictEqual(this.subject.header().name(), "unpinned");
});
test("pinning", async function (assert) {
this.siteSettings.automatically_unpin_topics = false;
this.set("subject", selectKit());
const store = getOwner(this).lookup("service:store");
this.set(
"topic",
store.createRecord("topic", {
id: 1234,
title: "Qunit Test Topic",
deleted_at: new Date(),
pinned: false,
})
);
await render(
hbs`<PinnedOptions @value={{this.topic.pinned}} @topic={{this.topic}} />`
);
assert.strictEqual(this.subject.header().name(), "unpinned");
await this.subject.expand();
await this.subject.selectRowByValue("pinned");
assert.strictEqual(this.subject.header().name(), "pinned");
});
});