MCPcopy Create free account
hub / github.com/denoland/std / checkParseFormat

Function checkParseFormat

path/parse_format_test.ts:92–115  ·  view source on GitHub ↗
(
  path: typeof windows | typeof posix,
  testCases: Array<[string, string, string?]>,
)

Source from the content-addressed store, hash-verified

90];
91
92function checkParseFormat(
93 path: typeof windows | typeof posix,
94 testCases: Array<[string, string, string?]>,
95) {
96 testCases.forEach(([element, root, formatted]) => {
97 const output = path.parse(element);
98 assertEquals(typeof output.root, "string");
99 assertEquals(typeof output.dir, "string");
100 assertEquals(typeof output.base, "string");
101 assertEquals(typeof output.ext, "string");
102 assertEquals(typeof output.name, "string");
103 assertEquals(output.root, root);
104 assertEquals(output.dir, output.dir ? path.dirname(element) : "");
105 assertEquals(output.base, path.basename(element));
106 assertEquals(output.ext, path.extname(element));
107 // We normalize incorrect paths during parsing, so some "incorrect"
108 // input cannot be asserted for equality onto itself.
109 if (formatted) {
110 assertEquals(path.format(output), formatted);
111 } else {
112 assertEquals(path.format(output), element);
113 }
114 });
115}
116
117function checkSpecialCaseParseFormat(
118 path: typeof windows | typeof posix,

Callers 1

Calls 4

assertEqualsFunction · 0.90
forEachMethod · 0.80
formatMethod · 0.80
parseMethod · 0.45

Tested by

no test coverage detected