summaryrefslogtreecommitdiff
path: root/Libraries/LibJS/Tests/builtins/Object/Object.getOwnPropertyDescriptor.js
blob: a1783add2cf9e0ff50fe5d577d3badf8d5d3f3b1 (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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
test("plain property", () => {
    let o = { foo: "bar" };

    expect(o).toHaveConfigurableProperty("foo");
    expect(o).toHaveEnumerableProperty("foo");
    expect(o).toHaveWritableProperty("foo");
    expect(o).toHaveValueProperty("foo", "bar");
    expect(o).not.toHaveGetterProperty("foo");
    expect(o).not.toHaveSetterProperty("foo");
});

test("getter property", () => {
    let o = { get foo() {} };

    expect(o).toHaveConfigurableProperty("foo");
    expect(o).toHaveEnumerableProperty("foo");
    expect(o).not.toHaveWritableProperty("foo");
    expect(o).not.toHaveValueProperty("foo");
    expect(o).toHaveGetterProperty("foo");
    expect(o).not.toHaveSetterProperty("foo");
});

test("setter property", () => {
    let o = { set foo(_) {} };

    expect(o).toHaveConfigurableProperty("foo");
    expect(o).toHaveEnumerableProperty("foo");
    expect(o).not.toHaveWritableProperty("foo");
    expect(o).not.toHaveValueProperty("foo");
    expect(o).not.toHaveGetterProperty("foo");
    expect(o).toHaveSetterProperty("foo");
});

test("defined property", () => {
    let o = {};

    Object.defineProperty(o, "foo", {
        enumerable: false,
        writable: true,
        value: 10,
    });

    expect(o).not.toHaveConfigurableProperty("foo");
    expect(o).not.toHaveEnumerableProperty("foo");
    expect(o).toHaveWritableProperty("foo");
    expect(o).toHaveValueProperty("foo", 10);
    expect(o).not.toHaveGetterProperty("foo");
    expect(o).not.toHaveSetterProperty("foo");
});