mirror of
https://github.com/coder/coder.git
synced 2026-11-16 00:01:29 +08:00
18 lines
439 B
TypeScript
18 lines
439 B
TypeScript
import { firstOrItem } from "./array"
|
|
|
|
describe("array", () => {
|
|
describe("firstOrItem", () => {
|
|
it("returns null if empty array", () => {
|
|
expect(firstOrItem([], null)).toBeNull()
|
|
})
|
|
|
|
it("returns first item if array with more one item", () => {
|
|
expect(firstOrItem(["a", "b"], "c")).toEqual("a")
|
|
})
|
|
|
|
it("returns item if single item", () => {
|
|
expect(firstOrItem("c", "d")).toEqual("c")
|
|
})
|
|
})
|
|
})
|