summaryrefslogtreecommitdiff
path: root/std/path/common_test.ts
blob: 7b7bd2ba394ff41650e92180614b365281524146 (plain)
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
// Copyright 2018-2020 the Deno authors. All rights reserved. MIT license.
import { assertEquals } from "../testing/asserts.ts";
import { common } from "./mod.ts";

Deno.test({
  name: "path - common - basic usage",
  fn() {
    const actual = common(
      [
        "file://deno/cli/js/deno.ts",
        "file://deno/std/path/mod.ts",
        "file://deno/cli/js/main.ts",
      ],
      "/",
    );
    assertEquals(actual, "file://deno/");
  },
});

Deno.test({
  name: "path - common - no shared",
  fn() {
    const actual = common(
      ["file://deno/cli/js/deno.ts", "https://deno.land/std/path/mod.ts"],
      "/",
    );
    assertEquals(actual, "");
  },
});

Deno.test({
  name: "path - common - windows sep",
  fn() {
    const actual = common(
      [
        "c:\\deno\\cli\\js\\deno.ts",
        "c:\\deno\\std\\path\\mod.ts",
        "c:\\deno\\cli\\js\\main.ts",
      ],
      "\\",
    );
    assertEquals(actual, "c:\\deno\\");
  },
});