1
0
mirror of https://github.com/matrix-org/matrix-react-sdk.git synced 2025-08-07 21:23:00 +03:00

Integrate compound design tokens (#11091)

* Integrate compound design tokens

The icons should not be included in this repo, and should live in the compound design token repo, but for simplicity sake at this phase of the integration they will be added here

* lintfix

* Use correct SpyInstance import

* Using npm build of design tokens
This commit is contained in:
Germain
2023-06-14 16:49:14 +01:00
committed by GitHub
parent b9b93264b6
commit 4243847f4f
5 changed files with 222 additions and 3 deletions

View File

@@ -22,6 +22,7 @@ describe("theme", () => {
let darkTheme: HTMLStyleElement;
let spyQuerySelectorAll: jest.MockInstance<NodeListOf<Element>, [selectors: string]>;
let spyClassList: jest.SpyInstance<void, string[], any>;
beforeEach(() => {
const styles = [
@@ -47,6 +48,7 @@ describe("theme", () => {
jest.spyOn(document.body, "style", "get").mockReturnValue([] as any);
spyQuerySelectorAll = jest.spyOn(document, "querySelectorAll").mockReturnValue(styles as any);
spyClassList = jest.spyOn(document.body.classList, "add");
});
afterEach(() => {
@@ -66,6 +68,18 @@ describe("theme", () => {
expect(spyQuerySelectorAll).toHaveBeenCalledTimes(1);
expect(lightTheme.disabled).toBe(false);
expect(darkTheme.disabled).toBe(true);
expect(spyClassList).toHaveBeenCalledWith("cpd-theme-light");
});
it("should switch to dark", async () => {
// When
await new Promise((resolve) => {
setTheme("dark").then(resolve);
darkTheme.onload!({} as Event);
});
// Then
expect(spyClassList).toHaveBeenCalledWith("cpd-theme-dark");
});
it("should reject promise on onerror call", () => {