Files
discourse/app/assets/javascripts/discourse/tests/unit/services/site-settings-test.js
Jarek Radosz ef7518d4ad DEV: Fix no-loose-assertions lint (#29965)
and enable some of qunit lints
2024-11-28 11:22:27 +01:00

38 lines
1.1 KiB
JavaScript

import EmberObject, { computed } from "@ember/object";
import { getOwner } from "@ember/owner";
import { service } from "@ember/service";
import { setupTest } from "ember-qunit";
import { module, test } from "qunit";
class TestClass extends EmberObject {
@service siteSettings;
@computed("siteSettings.title")
get text() {
return `The title: ${this.siteSettings.title}`;
}
}
module("Unit | Service | site-settings", function (hooks) {
setupTest(hooks);
hooks.beforeEach(function () {
this.siteSettings = getOwner(this).lookup("service:site-settings");
});
test("contains settings", function (assert) {
assert.strictEqual(typeof this.siteSettings.title, "string");
});
test("notifies getters", function (assert) {
this.siteSettings.title = "original";
getOwner(this).register("test-class:main", TestClass);
const object = getOwner(this).lookup("test-class:main");
assert.strictEqual(object.text, "The title: original");
this.siteSettings.title = "updated";
assert.strictEqual(object.text, "The title: updated");
});
});