Fix Notifier import cycle (#34122)
* Fix Notifier import cycle * Fix tests * Delint * Iterate * Handle SDKContextClass `client` initialisation internally Rather than via MatrixChat - this is predominantly for Lifecycle tests as they don't use a MatrixChat and it doesn't make much sense for this component to own this state. * Fix tests * Iterate * Improve coverage * Improve coverage * Fix bad merge * Iterate
This commit is contained in:
@@ -26,8 +26,8 @@ import { type FeatureSettingKey, type SettingKey } from "../../src/settings/Sett
|
||||
import { SettingLevel } from "../../src/settings/SettingLevel.ts";
|
||||
import SdkConfig from "../../src/SdkConfig.ts";
|
||||
import { BugReportEndpointURLLocal } from "../../src/IConfigOptions.ts";
|
||||
import { Notifier } from "../../src/Notifier.ts";
|
||||
import { MatrixClientPeg } from "../../src/MatrixClientPeg.ts";
|
||||
import { SDKContextClass } from "../../src/contexts/SDKContextClass.ts";
|
||||
|
||||
describe("Rageshakes", () => {
|
||||
let mockClient: Mocked<MatrixClient>;
|
||||
@@ -360,7 +360,7 @@ describe("Rageshakes", () => {
|
||||
|
||||
describe("Settings Store", () => {
|
||||
beforeEach(() => {
|
||||
jest.spyOn(Notifier, "isPossible").mockReturnValue(true);
|
||||
jest.spyOn(SDKContextClass.instance.notifier, "isPossible").mockReturnValue(true);
|
||||
});
|
||||
|
||||
afterEach(() => {
|
||||
@@ -406,7 +406,7 @@ describe("Rageshakes", () => {
|
||||
it("should handle settings throwing when logged out", async () => {
|
||||
jest.mocked(MatrixClientPeg.get).mockRestore();
|
||||
jest.mocked(MatrixClientPeg.safeGet).mockRestore();
|
||||
jest.spyOn(Notifier, "isPossible").mockImplementation(() => {
|
||||
jest.spyOn(SDKContextClass.instance.notifier, "isPossible").mockImplementation(() => {
|
||||
throw new Error("Test");
|
||||
});
|
||||
|
||||
@@ -419,7 +419,7 @@ describe("Rageshakes", () => {
|
||||
it("should handle reading notification settings when logged out", async () => {
|
||||
jest.mocked(MatrixClientPeg.get).mockRestore();
|
||||
jest.mocked(MatrixClientPeg.safeGet).mockRestore();
|
||||
jest.spyOn(Notifier, "isPossible").mockReturnValue(true);
|
||||
jest.spyOn(SDKContextClass.instance.notifier, "isPossible").mockReturnValue(true);
|
||||
|
||||
const formData = await collectBugReport();
|
||||
expect(JSON.parse(formData.get("mx_local_settings") as string)["notificationsEnabled"]).toBe(false);
|
||||
|
||||
Reference in New Issue
Block a user