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/d-navigation-test.js
Jarek Radosz 189bebb2e4
DEV: Modernize component tests (#17368)
* Use QUnit `module` instead of `discourseModule`
* Use QUnit `test` instead of `componentTest`
* Use angle-bracket syntax
* Remove jQuery usage
* Improve assertions (and actually fix some of them)
2022-07-11 12:29:44 +02:00

37 lines
1.1 KiB
JavaScript

import { module, test } from "qunit";
import { setupRenderingTest } from "discourse/tests/helpers/component-test";
import { click, render } from "@ember/test-helpers";
import { count, query } from "discourse/tests/helpers/qunit-helpers";
import hbs from "htmlbars-inline-precompile";
module("Integration | Component | d-navigation", function (hooks) {
setupRenderingTest(hooks);
hooks.beforeEach(function () {
const categories = this.site.categoriesList
.filter((category) => !category.parent_category_id)
.slice(0, 4);
this.site.setProperties({ categories });
this.currentUser.set(
"indirectly_muted_category_ids",
categories.slice(0, 3).map((category) => category.id)
);
});
test("filters indirectly muted categories", async function (assert) {
await render(hbs`<DNavigation @filterType="categories" />`);
await click(".category-drop .select-kit-header-wrapper");
assert.strictEqual(
count(".category-row"),
1,
"displays only categories that are not muted"
);
assert.strictEqual(
query(".category-row .badge-category span").textContent.trim(),
"dev"
);
});
});