summaryrefslogtreecommitdiff
path: root/Userland/Libraries/LibJS/Tests/builtins/Array/Array.isArray.js
blob: bbe12a8c445bd6b6e6d69f001b8a0fea1c48443d (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
test("length is 1", () => {
    expect(Array.isArray).toHaveLength(1);
});

test("arguments that evaluate to false", () => {
    expect(Array.isArray()).toBeFalse();
    expect(Array.isArray("1")).toBeFalse();
    expect(Array.isArray("foo")).toBeFalse();
    expect(Array.isArray(1)).toBeFalse();
    expect(Array.isArray(1, 2, 3)).toBeFalse();
    expect(Array.isArray(undefined)).toBeFalse();
    expect(Array.isArray(null)).toBeFalse();
    expect(Array.isArray(Infinity)).toBeFalse();
    expect(Array.isArray({})).toBeFalse();
});

test("arguments that evaluate to true", () => {
    expect(Array.isArray([])).toBeTrue();
    expect(Array.isArray([1])).toBeTrue();
    expect(Array.isArray([1, 2, 3])).toBeTrue();
    expect(Array.isArray(new Array())).toBeTrue();
    expect(Array.isArray(new Array(10))).toBeTrue();
    expect(Array.isArray(new Array("a", "b", "c"))).toBeTrue();
    // FIXME: Array.prototype is supposed to be an array!
    // expect(Array.isArray(Array.prototype)).toBeTrue();
});