| 1 | import * as DenoPath from "@effect/platform-deno/DenoPath" |
| 2 | import { assert, it } from "@effect/vitest" |
| 3 | import { Effect, Path } from "effect" |
| 4 | |
| 5 | it.layer(DenoPath.layer)("Integration", (it) => { |
| 6 | it.effect("runs the demo program", () => |
| 7 | Effect.gen(function*() { |
| 8 | // Access the Path service |
| 9 | const path = yield* Path.Path |
| 10 | |
| 11 | // Join parts of a path to create a complete file path |
| 12 | const tmpPath = path.join("tmp", "file.txt") |
| 13 | |
| 14 | assert.strictEqual(tmpPath, "tmp/file.txt") |
| 15 | })) |
| 16 | }) |
| 17 | |
| 18 | it.layer(DenoPath.layerPosix)("POSIX file URLs", (it) => { |
| 19 | it.effect("uses POSIX conversions", () => |
| 20 | Effect.gen(function*() { |
| 21 | const path = yield* Path.Path |
| 22 | |
| 23 | assert.strictEqual(yield* path.fromFileUrl(new URL("file:///tmp/file.txt")), "/tmp/file.txt") |
| 24 | assert.strictEqual((yield* path.toFileUrl("/tmp/file.txt")).href, "file:///tmp/file.txt") |
| 25 | })) |
| 26 | }) |
| 27 | |
| 28 | it.layer(DenoPath.layerWin32)("Windows file URLs", (it) => { |
| 29 | it.effect("uses Windows conversions", () => |
| 30 | Effect.gen(function*() { |
| 31 | const path = yield* Path.Path |
| 32 | |
| 33 | assert.strictEqual(yield* path.fromFileUrl(new URL("file:///C:/Users/me/file.txt")), "C:\\Users\\me\\file.txt") |
| 34 | assert.strictEqual( |
| 35 | (yield* path.toFileUrl("C:\\Users\\me\\file.txt")).href, |
| 36 | "file:///C:/Users/me/file.txt" |
| 37 | ) |
| 38 | })) |
| 39 | }) |