Skip to content
Source
Sign inSign up
fuko/trytanstackdb.com
Open History to see the last commit

app-screen.test.ts

25 lines897 Bytes

1import { describe, expect, it } from "vite-plus/test";
2​
3import { isOnScreen } from "./app-screen";
4​
5describe("isOnScreen", () => {
6 it("matches the screen itself", () => {
7 expect(isOnScreen("/folders/work", "/folders/work")).toBe(true);
8 expect(isOnScreen("/folders/work/", "/folders/work")).toBe(true);
9 });
10​
11 it("matches screens pushed on top of it", () => {
12 expect(isOnScreen("/folders/work/notes/n4", "/folders/work")).toBe(true);
13 });
14​
15 it("doesn't match sibling screens that share a prefix", () => {
16 expect(isOnScreen("/folders/workshop", "/folders/work")).toBe(false);
17 expect(isOnScreen("/folders/personal", "/folders/work")).toBe(false);
18 });
19​
20 it("only matches the root screen exactly", () => {
21 expect(isOnScreen("/", "/")).toBe(true);
22 expect(isOnScreen("/folders/work", "/")).toBe(false);
23 expect(isOnScreen("/settings", "/")).toBe(false);
24 });
25});