Skip to content

Commit

Permalink
test: Add test for traversed
Browse files Browse the repository at this point in the history
  • Loading branch information
MikuroXina committed Aug 15, 2024
1 parent 1ea254c commit 75564ef
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion src/optical/traversal.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import { overCat } from "../optical.ts";
import { bitraversable, type Tuple } from "../tuple.ts";
import { both } from "./traversal.ts";
import { both, traversed } from "./traversal.ts";
import { assertEquals } from "../../deps.ts";
import { Array } from "../../mod.ts";

Deno.test("get length of string for each element of tuple", () => {
const tuple: Tuple<string, string> = ["hello", "world"];
Expand All @@ -12,3 +13,13 @@ Deno.test("get length of string for each element of tuple", () => {
[5, 5],
);
});

Deno.test("traversed", () => {
const values = ["hey", "what", "are", "you", "doing"];
assertEquals(
overCat((s: string) => s.length)
.on(traversed(Array.traversable))
.from(values),
[3, 4, 3, 3, 5],
);
});

0 comments on commit 75564ef

Please sign in to comment.