mirror of
https://github.com/LadybirdBrowser/ladybird
synced 2026-05-01 03:57:15 +02:00
LibJS: Move tests to /Tests/LibJS
This commit is contained in:
committed by
Tim Flynn
parent
c059c6a2f5
commit
e3faa9b5ad
Notes:
github-actions[bot]
2026-02-06 11:17:48 +00:00
Author: https://github.com/gmta Commit: https://github.com/LadybirdBrowser/ladybird/commit/e3faa9b5add Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/7572 Reviewed-by: https://github.com/trflynn89 ✅
54
Tests/LibJS/Runtime/builtins/Object/Object.create.js
Normal file
54
Tests/LibJS/Runtime/builtins/Object/Object.create.js
Normal file
@@ -0,0 +1,54 @@
|
||||
test("length is 2", () => {
|
||||
expect(Object.create).toHaveLength(2);
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("non-object prototype value", () => {
|
||||
expect(() => Object.create(42)).toThrowWithMessage(TypeError, "Prototype must be an object or null");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("creates object with given prototype", () => {
|
||||
let o;
|
||||
|
||||
o = Object.create(null);
|
||||
expect(o).toEqual({});
|
||||
expect(Object.getPrototypeOf(o)).toBe(null);
|
||||
|
||||
const p = {};
|
||||
o = Object.create(p);
|
||||
expect(o).toEqual({});
|
||||
expect(Object.getPrototypeOf(o)).toBe(p);
|
||||
});
|
||||
|
||||
test("creates object with properties from propertiesObject, if given", () => {
|
||||
const o = Object.create(
|
||||
{},
|
||||
{
|
||||
foo: {
|
||||
writable: true,
|
||||
configurable: true,
|
||||
value: "foo",
|
||||
},
|
||||
bar: {
|
||||
enumerable: true,
|
||||
value: "bar",
|
||||
},
|
||||
}
|
||||
);
|
||||
expect(Object.getOwnPropertyNames(o)).toEqual(["foo", "bar"]);
|
||||
expect(Object.getOwnPropertyDescriptor(o, "foo")).toEqual({
|
||||
value: "foo",
|
||||
writable: true,
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
});
|
||||
expect(Object.getOwnPropertyDescriptor(o, "bar")).toEqual({
|
||||
value: "bar",
|
||||
writable: false,
|
||||
enumerable: true,
|
||||
configurable: false,
|
||||
});
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user