deno.land / std@0.224.0 / path / resolve_test.ts

resolve_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
// Copyright 2018-2024 the Deno authors. All rights reserved. MIT license.// Copyright the Browserify authors. MIT License.// Ported from https://github.com/browserify/path-browserify/import { assertEquals } from "../assert/mod.ts";import * as posix from "./posix/mod.ts";import * as windows from "./windows/mod.ts";import { resolve } from "./resolve.ts";
const windowsTests = // arguments result [ [["c:/blah\\blah", "d:/games", "c:../a"], "c:\\blah\\a"], [["c:/ignore", "d:\\a/b\\c/d", "\\e.exe"], "d:\\e.exe"], [["c:/ignore", "c:/some/file"], "c:\\some\\file"], [["d:/ignore", "d:some/dir//"], "d:\\ignore\\some\\dir"], [["//server/share", "..", "relative\\"], "\\\\server\\share\\relative"], [["c:/", "//"], "c:\\"], [["c:/", "//dir"], "c:\\dir"], [["c:/", "//server/share"], "\\\\server\\share\\"], [["c:/", "//server//share"], "\\\\server\\share\\"], [["c:/", "///some//dir"], "c:\\some\\dir"], [ ["C:\\foo\\tmp.3\\", "..\\tmp.3\\cycles\\root.js"], "C:\\foo\\tmp.3\\cycles\\root.js", ], ];const posixTests = // arguments result [ [["/var/lib", "../", "file/"], "/var/file"], [["/var/lib", "/../", "file/"], "/file"], [["a/b/c/", "../../.."], Deno.cwd()], [["."], Deno.cwd()], [["/some/dir", ".", "/absolute/"], "/absolute"], [["/foo/tmp.3/", "../tmp.3/cycles/root.js"], "/foo/tmp.3/cycles/root.js"], ];
Deno.test("posix.resolve()", function () { posixTests.forEach(function (p) { const _p = p[0] as string[]; const actual = posix.resolve.apply(null, _p); assertEquals(actual, p[1]); });});
Deno.test("windows.resolve()", function () { windowsTests.forEach(function (p) { const _p = p[0] as string[]; const actual = windows.resolve.apply(null, _p); assertEquals(actual, p[1]); });});
Deno.test("resolve() returns current working directory if input is empty", function () { const pwd = Deno.cwd(); assertEquals(resolve(""), pwd); assertEquals(resolve("", ""), pwd);});
std

Version Info

Tagged at
6 months ago