From 75564ef841a5f7a0b5b00ccc67e0b8d92d877e6c Mon Sep 17 00:00:00 2001 From: MikuroXina Date: Thu, 15 Aug 2024 12:55:18 +0900 Subject: [PATCH] test: Add test for traversed --- src/optical/traversal.test.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/optical/traversal.test.ts b/src/optical/traversal.test.ts index 7d5ac039..5f4aac7c 100644 --- a/src/optical/traversal.test.ts +++ b/src/optical/traversal.test.ts @@ -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 = ["hello", "world"]; @@ -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], + ); +});