deno.land / std@0.224.0 / fs / _is_same_path_test.ts

_is_same_path_test.ts
View Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// Copyright the Browserify authors. MIT License.
import { assertEquals } from "../assert/mod.ts";import * as path from "../path/mod.ts";import { isSamePath } from "./_is_same_path.ts";
Deno.test({ name: "isSamePath() works correctly for win32", ignore: Deno.build.os !== "windows", fn() { const pairs: (string | URL | boolean)[][] = [ ["", "", true], ["C:\\test", "C:\\test", true], ["C:\\test", "C:\\test\\test", false], ["C:\\test", path.toFileUrl("C:\\test"), true], ["C:\\test", path.toFileUrl("C:\\test\\test"), false], ];
for (const p of pairs) { const src = p[0] as string | URL; const dest = p[1] as string | URL; const expected = p[2] as boolean;
assertEquals( isSamePath(src, dest), expected, `'${src}' should ${expected ? "" : "not"} be the same as '${dest}'`, ); } },});
Deno.test({ name: "isSamePath() works correctly for posix", ignore: Deno.build.os === "windows", fn() { const pairs: (string | URL | boolean)[][] = [ ["", "", true], ["/test", "/test/", true], ["/test", "/test/test", false], ["/test", "/test/test/..", true], ["/test", path.toFileUrl("/test"), true], ["/test", path.toFileUrl("/test/test"), false], ];
for (const p of pairs) { const src = p[0] as string | URL; const dest = p[1] as string | URL; const expected = p[2] as boolean;
assertEquals( isSamePath(src, dest), expected, `'${src}' should ${expected ? "" : "not"} be the same as '${dest}'`, ); } },});
std

Version Info

Tagged at
6 months ago