mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-08-12 11:09:18 +00:00
Everywhere: Hoist the Libraries folder to the top-level
This commit is contained in:
parent
950e819ee7
commit
93712b24bf
Notes:
github-actions[bot]
2024-11-10 11:51:52 +00:00
Author: https://github.com/trflynn89
Commit: 93712b24bf
Pull-request: https://github.com/LadybirdBrowser/ladybird/pull/2256
Reviewed-by: https://github.com/sideshowbarker
4547 changed files with 104 additions and 113 deletions
42
Libraries/LibJS/Tests/builtins/Object/Object.assign.js
Normal file
42
Libraries/LibJS/Tests/builtins/Object/Object.assign.js
Normal file
|
@ -0,0 +1,42 @@
|
|||
test("length is 2", () => {
|
||||
expect(Object.assign).toHaveLength(2);
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("first argument must coercible to object", () => {
|
||||
expect(() => {
|
||||
Object.assign(null);
|
||||
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
|
||||
expect(() => {
|
||||
Object.assign(undefined);
|
||||
}).toThrowWithMessage(TypeError, "ToObject on null or undefined");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("returns first argument coerced to object", () => {
|
||||
const o = {};
|
||||
expect(Object.assign(o)).toBe(o);
|
||||
expect(Object.assign(o, {})).toBe(o);
|
||||
expect(Object.assign(42)).toEqual(new Number(42));
|
||||
});
|
||||
|
||||
test("alters first argument object if sources are given", () => {
|
||||
const o = { foo: 0 };
|
||||
expect(Object.assign(o, { foo: 1 })).toBe(o);
|
||||
expect(o).toEqual({ foo: 1 });
|
||||
});
|
||||
|
||||
test("merges objects", () => {
|
||||
const s = Symbol();
|
||||
expect(
|
||||
Object.assign(
|
||||
{},
|
||||
{ foo: 0, bar: "baz" },
|
||||
{ [s]: [1, 2, 3] },
|
||||
{ foo: 1 },
|
||||
{ [42]: "test" }
|
||||
)
|
||||
).toEqual({ foo: 1, bar: "baz", [s]: [1, 2, 3], 42: "test" });
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue