2024-07-25 21:09:06 +08:00
|
|
|
import { getOwner } from "@ember/owner";
|
2023-09-27 01:05:34 +08:00
|
|
|
import { setupTest } from "ember-qunit";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { module, test } from "qunit";
|
|
|
|
import { ORIGINS } from "discourse/plugins/chat/discourse/services/chat-channel-info-route-origin-manager";
|
2022-11-02 21:41:30 +08:00
|
|
|
|
|
|
|
module(
|
|
|
|
"Discourse Chat | Unit | Service | chat-channel-info-route-origin-manager",
|
|
|
|
function (hooks) {
|
2023-09-27 01:05:34 +08:00
|
|
|
setupTest(hooks);
|
|
|
|
|
2022-11-02 21:41:30 +08:00
|
|
|
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) {
|
2024-03-19 19:07:19 +08:00
|
|
|
this.manager.origin = ORIGINS.channel;
|
|
|
|
assert.strictEqual(this.manager.origin, ORIGINS.channel);
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test(".isBrowse", function (assert) {
|
|
|
|
this.manager.origin = ORIGINS.browse;
|
2024-03-19 19:07:19 +08:00
|
|
|
assert.true(this.manager.isBrowse);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
|
|
|
this.manager.origin = null;
|
2024-03-19 19:07:19 +08:00
|
|
|
assert.false(this.manager.isBrowse);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
|
|
|
this.manager.origin = ORIGINS.channel;
|
2024-03-19 19:07:19 +08:00
|
|
|
assert.false(this.manager.isBrowse);
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
test(".isChannel", function (assert) {
|
2024-03-19 19:07:19 +08:00
|
|
|
this.manager.origin = ORIGINS.channel;
|
|
|
|
assert.true(this.manager.isChannel);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
|
|
|
this.manager.origin = ORIGINS.browse;
|
2024-03-19 19:07:19 +08:00
|
|
|
assert.false(this.manager.isChannel);
|
2022-11-02 21:41:30 +08:00
|
|
|
|
|
|
|
this.manager.origin = null;
|
2024-03-19 19:07:19 +08:00
|
|
|
assert.true(this.manager.isChannel);
|
2022-11-02 21:41:30 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
);
|