mirror of
https://github.com/excalidraw/excalidraw.git
synced 2025-05-03 10:00:07 -04:00
feat: Add theme prop (#3228)
* support appearance when updating scene data * works! * whoops, missed a prop * hide appearance button when prop is not set * cleanup * fix export + rename prop to theme * rename to showThemeBtn, hide via react instead of css * adapt to new state name * add tests and css selector to target the dark mode toggle * updated changelog and readme * fix markdown rendering in readme * pr feedback
This commit is contained in:
parent
1f295955d0
commit
84a1863233
10 changed files with 62 additions and 10 deletions
|
@ -1,7 +1,7 @@
|
|||
import React from "react";
|
||||
import { fireEvent, GlobalTestState, render } from "./test-utils";
|
||||
import Excalidraw from "../packages/excalidraw/index";
|
||||
import { queryByText } from "@testing-library/react";
|
||||
import { queryByText, queryByTestId } from "@testing-library/react";
|
||||
import { GRID_SIZE } from "../constants";
|
||||
|
||||
const { h } = window;
|
||||
|
@ -86,4 +86,22 @@ describe("<Excalidraw/>", () => {
|
|||
expect(h.state.gridSize).toBe(null);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Test theme prop", () => {
|
||||
it('should show the dark mode toggle when the theme prop is "undefined"', async () => {
|
||||
const { container } = await render(<Excalidraw />);
|
||||
expect(h.state.theme).toBe("light");
|
||||
|
||||
const darkModeToggle = queryByTestId(container, "toggle-dark-mode");
|
||||
|
||||
expect(darkModeToggle).toBeTruthy();
|
||||
});
|
||||
|
||||
it('should not show the dark mode toggle when the theme prop is not "undefined"', async () => {
|
||||
const { container } = await render(<Excalidraw theme="dark" />);
|
||||
expect(h.state.theme).toBe("dark");
|
||||
|
||||
expect(queryByTestId(container, "toggle-dark-mode")).toBe(null);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue