Please wait. This can take some minutes ...
Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance.
Project price only 1 $
You can buy this project and download/modify it how often you want.
__tests__.string-utils.test.js Maven / Gradle / Ivy
import { F } from "helpers/formatter"
test('basic pretty list', () => {
expect(F.toList([])).toEqual("")
expect(F.toList(["one"])).toEqual("one")
expect(F.toList(["one", "two"], " and ")).toEqual("one and two")
expect(F.toList(["one", "two", "three"], " and ")).toEqual("one, two and three")
})
test('limited pretty list', () => {
expect(F.toList([], " and ", 1)).toEqual("")
expect(F.toList(["one"], " and ", 1)).toEqual("one")
expect(F.toList(["one", "two"], " and ", 1)).toEqual("one, ...")
expect(F.toList(["one", "two", "three"], " and ", 2)).toEqual("one, ... and three")
expect(F.toList(["one", "two", "three", "four"], " and ", 2)).toEqual("one, ... and four")
expect(F.toList(["one", "two", "three", "four"], " and ", 3)).toEqual("one, two, ... and four")
expect(F.toList(["one", "two", "three", "four"], " and ", 4)).toEqual("one, two, three and four")
})
test('different delimiters', () => {
expect(F.toList([], " and ", 1, "; ")).toEqual("")
expect(F.toList(["one"], " and ", 1, "; ")).toEqual("one")
expect(F.toList(["one", "two"], " and ", 1, "; ")).toEqual("one; ...")
expect(F.toList(["one", "two", "three"], " # ", 2, "; ")).toEqual("one; ... # three")
expect(F.toList(["one", "two", "three"], " # ", 3, "; ")).toEqual("one; two # three")
})