diff options
| author | Adam Malczewski <[email protected]> | 2026-06-26 22:21:55 +0900 |
|---|---|---|
| committer | Adam Malczewski <[email protected]> | 2026-06-26 22:23:39 +0900 |
| commit | 9b0b4e5ef52c5e4383d6c4a2041ca1a73ea4bc44 (patch) | |
| tree | db67a714911ab7cfa70c054c6951ffca1c58550d /src/features/workspaces/logic/route.test.ts | |
| parent | 306f28a7732e11e3de1c6d0c4d26cadb92b25d3e (diff) | |
| download | dispatch-web-9b0b4e5ef52c5e4383d6c4a2041ca1a73ea4bc44.tar.gz dispatch-web-9b0b4e5ef52c5e4383d6c4a2041ca1a73ea4bc44.zip | |
style: switch from tabs to 2-space indentation (incl. svelte)
Diffstat (limited to 'src/features/workspaces/logic/route.test.ts')
| -rw-r--r-- | src/features/workspaces/logic/route.test.ts | 112 |
1 files changed, 56 insertions, 56 deletions
diff --git a/src/features/workspaces/logic/route.test.ts b/src/features/workspaces/logic/route.test.ts index a6da3e1..96e0ff3 100644 --- a/src/features/workspaces/logic/route.test.ts +++ b/src/features/workspaces/logic/route.test.ts @@ -1,77 +1,77 @@ import { describe, expect, it } from "vitest"; import { - DEFAULT_WORKSPACE_ID, - isValidSlug, - parsePath, - WORKSPACE_SLUG_RE, - workspacePath, + DEFAULT_WORKSPACE_ID, + isValidSlug, + parsePath, + WORKSPACE_SLUG_RE, + workspacePath, } from "./route"; describe("parsePath", () => { - it("treats the root path as home", () => { - expect(parsePath("/")).toEqual({ kind: "home" }); - expect(parsePath("")).toEqual({ kind: "home" }); - }); + it("treats the root path as home", () => { + expect(parsePath("/")).toEqual({ kind: "home" }); + expect(parsePath("")).toEqual({ kind: "home" }); + }); - it("trims surrounding slashes", () => { - expect(parsePath("//")).toEqual({ kind: "home" }); - expect(parsePath("/my-ws/")).toEqual({ kind: "workspace", id: "my-ws" }); - }); + it("trims surrounding slashes", () => { + expect(parsePath("//")).toEqual({ kind: "home" }); + expect(parsePath("/my-ws/")).toEqual({ kind: "workspace", id: "my-ws" }); + }); - it("parses a single segment as a workspace id", () => { - expect(parsePath("/default")).toEqual({ kind: "workspace", id: "default" }); - expect(parsePath("/my-workspace")).toEqual({ kind: "workspace", id: "my-workspace" }); - expect(parsePath("/ws1")).toEqual({ kind: "workspace", id: "ws1" }); - }); + it("parses a single segment as a workspace id", () => { + expect(parsePath("/default")).toEqual({ kind: "workspace", id: "default" }); + expect(parsePath("/my-workspace")).toEqual({ kind: "workspace", id: "my-workspace" }); + expect(parsePath("/ws1")).toEqual({ kind: "workspace", id: "ws1" }); + }); - it("takes only the first segment of a deeper path", () => { - expect(parsePath("/foo/bar")).toEqual({ kind: "workspace", id: "foo" }); - expect(parsePath("/foo/bar/baz")).toEqual({ kind: "workspace", id: "foo" }); - }); + it("takes only the first segment of a deeper path", () => { + expect(parsePath("/foo/bar")).toEqual({ kind: "workspace", id: "foo" }); + expect(parsePath("/foo/bar/baz")).toEqual({ kind: "workspace", id: "foo" }); + }); - it("URL-decodes the segment", () => { - expect(parsePath("/my%20ws")).toEqual({ kind: "workspace", id: "my ws" }); - }); + it("URL-decodes the segment", () => { + expect(parsePath("/my%20ws")).toEqual({ kind: "workspace", id: "my ws" }); + }); - it("does not validate the slug — an invalid id is still a workspace route", () => { - expect(parsePath("/UPPER")).toEqual({ kind: "workspace", id: "UPPER" }); - expect(parsePath("/has space")).toEqual({ kind: "workspace", id: "has space" }); - }); + it("does not validate the slug — an invalid id is still a workspace route", () => { + expect(parsePath("/UPPER")).toEqual({ kind: "workspace", id: "UPPER" }); + expect(parsePath("/has space")).toEqual({ kind: "workspace", id: "has space" }); + }); }); describe("isValidSlug", () => { - it("accepts lowercase alphanumeric + internal hyphens", () => { - expect(isValidSlug("default")).toBe(true); - expect(isValidSlug("my-workspace")).toBe(true); - expect(isValidSlug("a")).toBe(true); - expect(isValidSlug("ws-1")).toBe(true); - }); + it("accepts lowercase alphanumeric + internal hyphens", () => { + expect(isValidSlug("default")).toBe(true); + expect(isValidSlug("my-workspace")).toBe(true); + expect(isValidSlug("a")).toBe(true); + expect(isValidSlug("ws-1")).toBe(true); + }); - it("accepts up to 40 chars", () => { - expect(isValidSlug("a".repeat(40))).toBe(true); - }); + it("accepts up to 40 chars", () => { + expect(isValidSlug("a".repeat(40))).toBe(true); + }); - it("rejects empty and too-long", () => { - expect(isValidSlug("")).toBe(false); - expect(isValidSlug("a".repeat(41))).toBe(false); - }); + it("rejects empty and too-long", () => { + expect(isValidSlug("")).toBe(false); + expect(isValidSlug("a".repeat(41))).toBe(false); + }); - it("rejects uppercase, spaces, and leading/trailing hyphens", () => { - expect(isValidSlug("MyWS")).toBe(false); - expect(isValidSlug("has space")).toBe(false); - expect(isValidSlug("-leading")).toBe(false); - expect(isValidSlug("trailing-")).toBe(false); - expect(isValidSlug("double--hyphen")).toBe(true); // internal doubles are allowed by the regex - }); + it("rejects uppercase, spaces, and leading/trailing hyphens", () => { + expect(isValidSlug("MyWS")).toBe(false); + expect(isValidSlug("has space")).toBe(false); + expect(isValidSlug("-leading")).toBe(false); + expect(isValidSlug("trailing-")).toBe(false); + expect(isValidSlug("double--hyphen")).toBe(true); // internal doubles are allowed by the regex + }); - it("WORKSPACE_SLUG_RE matches the default id", () => { - expect(WORKSPACE_SLUG_RE.test(DEFAULT_WORKSPACE_ID)).toBe(true); - }); + it("WORKSPACE_SLUG_RE matches the default id", () => { + expect(WORKSPACE_SLUG_RE.test(DEFAULT_WORKSPACE_ID)).toBe(true); + }); }); describe("workspacePath", () => { - it("builds the URL path for a workspace id", () => { - expect(workspacePath("default")).toBe("/default"); - expect(workspacePath("my-ws")).toBe("/my-ws"); - }); + it("builds the URL path for a workspace id", () => { + expect(workspacePath("default")).toBe("/default"); + expect(workspacePath("my-ws")).toBe("/my-ws"); + }); }); |
