discourse/plugins/chat/test/javascripts/unit/services/chat-channel-info-route-origin-manager-test.js
Jarek Radosz 038e5deb2a
DEV: Clean up imports (#28060)
* `@ember/owner` instead of `@ember/application`
* `discourse-i18n` instead of `I18n`
* `{ service } from "@ember/service"` instead of `inject as service`
2024-07-25 15:09:06 +02:00

49 lines
1.3 KiB
JavaScript

import { getOwner } from "@ember/owner";
import { setupTest } from "ember-qunit";
import { module, test } from "qunit";
import { ORIGINS } from "discourse/plugins/chat/discourse/services/chat-channel-info-route-origin-manager";
module(
"Discourse Chat | Unit | Service | chat-channel-info-route-origin-manager",
function (hooks) {
setupTest(hooks);
hooks.beforeEach(function () {
this.manager = getOwner(this).lookup(
"service:chat-channel-info-route-origin-manager"
);
});
hooks.afterEach(function () {
this.manager.origin = null;
});
test(".origin", function (assert) {
this.manager.origin = ORIGINS.channel;
assert.strictEqual(this.manager.origin, ORIGINS.channel);
});
test(".isBrowse", function (assert) {
this.manager.origin = ORIGINS.browse;
assert.true(this.manager.isBrowse);
this.manager.origin = null;
assert.false(this.manager.isBrowse);
this.manager.origin = ORIGINS.channel;
assert.false(this.manager.isBrowse);
});
test(".isChannel", function (assert) {
this.manager.origin = ORIGINS.channel;
assert.true(this.manager.isChannel);
this.manager.origin = ORIGINS.browse;
assert.false(this.manager.isChannel);
this.manager.origin = null;
assert.true(this.manager.isChannel);
});
}
);