rev.test.ts
This file
Path
apps/web/test/rev.test.ts
34 lines · 1.0 KiB · TypeScript
Last changed by
Merge build/comments-web-rest into mainoscabrielbefore adoption0eb1248
History of this fileTake it
Give the web its W9 dependencies, components, project nav, line and revision helpers, and a stub for every new pageoscabrielbefore adoption254268a
lines 1–34why, one step back1import { describe, expect, it } from "@effect/vitest";2import { Option } from "effect";34import { revOf, revSegment } from "../src/features/code/rev.ts";56const sha = "0123456789abcdef0123456789abcdef01234567";78const tag = "@changesets/cli@2.27.1";910describe("a revision in a path", () => {11 it.each(["main", sha])("keeps %s as it is", (rev) => {12 expect(revSegment(rev)).toBe(rev);13 expect(revOf(revSegment(rev))).toStrictEqual(Option.some(rev));14 });1516 it("puts a scoped tag in one segment, and reads it back", () => {17 const segment = revSegment(tag);1819 expect(segment).toBe("%40changesets%2Fcli%402.27.1");20 expect(segment).not.toContain("/");21 expect(revOf(segment)).toStrictEqual(Option.some(tag));22 });2324 it("reads a tag a browser left decoded", () => {25 expect(revOf("v1.0.0")).toStrictEqual(Option.some("v1.0.0"));26 });2728 it.each(["%", "%E0%A4%A", ""])(29 "names no revision in %j, without throwing",30 (segment) => {31 expect(revOf(segment)).toStrictEqual(Option.none());32 }33 );34});