/* * This file is part of CoCalc: Copyright © 2020 Sagemath, Inc. * License: AGPLv3 s.t. "Commons Clause" – see LICENSE.md for details */ import * as misc from "../misc"; describe("rpad_html", () => { const rp = misc.rpad_html; const round1 = misc.round1; test("0", () => expect(rp(0, 3)).toEqual(" 0")); test("99", () => expect(rp(99, 3)).toEqual(" 99")); test("4444-5", () => expect(rp(4444, 5)).toEqual(" 4444")); test("6666-4", () => expect(rp(6666, 4)).toEqual("6666")); test("1000-4", () => expect(rp(1000, 4)).toEqual("1000")); test("1000-3", () => expect(rp(1000, 3)).toEqual("1000")); test("pi-1", () => expect(rp(3.1415, 4, round1)).toEqual(" 3.1")); }); describe("path_split", () => { const ps = misc.path_split; test("full path", () => expect(ps("foo/bar")).toEqual({ head: "foo", tail: "bar" })); test("filename", () => expect(ps("foo.bar.baz")).toEqual({ head: "", tail: "foo.bar.baz" })); test("dirname", () => expect(ps("foo/")).toEqual({ head: "foo", tail: "" })); test("abspath", () => expect(ps("/HOME/USER/DIR")).toEqual({ head: "/HOME/USER", tail: "DIR", })); test("ROOT", () => expect(ps("/")).toEqual({ head: "", tail: "" })); }); describe("contains_url", () => { const cu = misc.contains_url; test("normal html is fine", () => expect(cu("