code-server/test/util.test.ts

19 lines
524 B
TypeScript
Raw Normal View History

2020-02-05 08:16:45 +08:00
import { normalize } from "../src/common/util"
2020-02-05 03:27:46 +08:00
describe("util", () => {
describe("normalize", () => {
it("should remove multiple slashes", () => {
2021-01-09 04:55:47 +08:00
expect(normalize("//foo//bar//baz///mumble")).toBe("/foo/bar/baz/mumble")
2020-02-05 03:27:46 +08:00
})
it("should remove trailing slashes", () => {
2021-01-09 04:55:47 +08:00
expect(normalize("qux///")).toBe("qux")
2020-02-05 03:27:46 +08:00
})
2020-02-05 08:16:45 +08:00
it("should preserve trailing slash if it exists", () => {
2021-01-09 04:55:47 +08:00
expect(normalize("qux///", true)).toBe("qux/")
expect(normalize("qux", true)).toBe("qux")
2020-02-05 08:16:45 +08:00
})
2020-02-05 03:27:46 +08:00
})
})