feat: dark mode by default
This commit is contained in:
@@ -0,0 +1,7 @@
|
|||||||
|
# Commit Style
|
||||||
|
|
||||||
|
- Use Conventional Commits.
|
||||||
|
- Keep the type and subject lowercase.
|
||||||
|
- Keep commit messages terse.
|
||||||
|
|
||||||
|
Example: `feat: dark mode by default`
|
||||||
@@ -20,6 +20,15 @@ function withApi() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
describe("api", () => {
|
describe("api", () => {
|
||||||
|
test("creates a drawing with dark theme by default", async () => {
|
||||||
|
const { api, cleanup } = withApi();
|
||||||
|
|
||||||
|
const created = await api.createDrawing().json();
|
||||||
|
|
||||||
|
expect(created.appState.theme).toBe("dark");
|
||||||
|
cleanup();
|
||||||
|
});
|
||||||
|
|
||||||
test("returns 400 for invalid JSON", async () => {
|
test("returns 400 for invalid JSON", async () => {
|
||||||
const { api, cleanup } = withApi();
|
const { api, cleanup } = withApi();
|
||||||
const drawing = await api.createDrawing().json();
|
const drawing = await api.createDrawing().json();
|
||||||
|
|||||||
@@ -27,6 +27,7 @@ describe("drawing store", () => {
|
|||||||
const created = store.createDrawing();
|
const created = store.createDrawing();
|
||||||
|
|
||||||
expect(created.title).toBe("Untitled");
|
expect(created.title).toBe("Untitled");
|
||||||
|
expect(created.scene.appState.theme).toBe("dark");
|
||||||
expect(store.listDrawings()).toHaveLength(1);
|
expect(store.listDrawings()).toHaveLength(1);
|
||||||
|
|
||||||
const updated = store.updateDrawing(created.id, {
|
const updated = store.updateDrawing(created.id, {
|
||||||
|
|||||||
+7
-1
@@ -1,7 +1,13 @@
|
|||||||
import { describe, expect, test } from "bun:test";
|
import { describe, expect, test } from "bun:test";
|
||||||
import { HttpError, MAX_SCENE_BYTES, normalizeScene, parseJsonBody } from "./scene";
|
import { HttpError, MAX_SCENE_BYTES, emptyScene, normalizeScene, parseJsonBody } from "./scene";
|
||||||
|
|
||||||
describe("scene helpers", () => {
|
describe("scene helpers", () => {
|
||||||
|
test("creates empty scenes with dark theme by default", () => {
|
||||||
|
const scene = emptyScene();
|
||||||
|
|
||||||
|
expect(scene.appState.theme).toBe("dark");
|
||||||
|
});
|
||||||
|
|
||||||
test("normalizes volatile app state fields", () => {
|
test("normalizes volatile app state fields", () => {
|
||||||
const scene = normalizeScene({
|
const scene = normalizeScene({
|
||||||
elements: [],
|
elements: [],
|
||||||
|
|||||||
+1
-1
@@ -26,7 +26,7 @@ const VOLATILE_APP_STATE_KEYS = new Set([
|
|||||||
export function emptyScene(): ScenePayload {
|
export function emptyScene(): ScenePayload {
|
||||||
return {
|
return {
|
||||||
elements: [],
|
elements: [],
|
||||||
appState: {},
|
appState: { theme: "dark" },
|
||||||
files: {},
|
files: {},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user