mirror of
https://github.com/LadybirdBrowser/ladybird.git
synced 2025-09-03 08:08:43 +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
|
@ -1,77 +0,0 @@
|
|||
test("length is 2", () => {
|
||||
expect(Object.groupBy).toHaveLength(2);
|
||||
});
|
||||
|
||||
describe("errors", () => {
|
||||
test("callback must be a function", () => {
|
||||
expect(() => {
|
||||
Object.groupBy([], undefined);
|
||||
}).toThrowWithMessage(TypeError, "undefined is not a function");
|
||||
});
|
||||
|
||||
test("null or undefined items value", () => {
|
||||
expect(() => {
|
||||
Object.groupBy();
|
||||
}).toThrowWithMessage(TypeError, "undefined cannot be converted to an object");
|
||||
|
||||
expect(() => {
|
||||
Object.groupBy(undefined);
|
||||
}).toThrowWithMessage(TypeError, "undefined cannot be converted to an object");
|
||||
|
||||
expect(() => {
|
||||
Object.groupBy(null);
|
||||
}).toThrowWithMessage(TypeError, "null cannot be converted to an object");
|
||||
});
|
||||
});
|
||||
|
||||
describe("normal behavior", () => {
|
||||
test("basic functionality", () => {
|
||||
const array = [1, 2, 3, 4, 5, 6];
|
||||
const visited = [];
|
||||
|
||||
const firstResult = Object.groupBy(array, value => {
|
||||
visited.push(value);
|
||||
return value % 2 === 0;
|
||||
});
|
||||
|
||||
expect(visited).toEqual([1, 2, 3, 4, 5, 6]);
|
||||
expect(firstResult.true).toEqual([2, 4, 6]);
|
||||
expect(firstResult.false).toEqual([1, 3, 5]);
|
||||
|
||||
const firstKeys = Object.keys(firstResult);
|
||||
expect(firstKeys).toHaveLength(2);
|
||||
expect(firstKeys[0]).toBe("false");
|
||||
expect(firstKeys[1]).toBe("true");
|
||||
|
||||
const secondResult = Object.groupBy(array, (_, index) => {
|
||||
return index < array.length / 2;
|
||||
});
|
||||
|
||||
expect(secondResult.true).toEqual([1, 2, 3]);
|
||||
expect(secondResult.false).toEqual([4, 5, 6]);
|
||||
|
||||
const secondKeys = Object.keys(secondResult);
|
||||
expect(secondKeys).toHaveLength(2);
|
||||
expect(secondKeys[0]).toBe("true");
|
||||
expect(secondKeys[1]).toBe("false");
|
||||
});
|
||||
|
||||
test("never calls callback with empty array", () => {
|
||||
var callbackCalled = 0;
|
||||
expect(
|
||||
Object.groupBy([], () => {
|
||||
callbackCalled++;
|
||||
})
|
||||
).toEqual({});
|
||||
expect(callbackCalled).toBe(0);
|
||||
});
|
||||
|
||||
test("calls callback once for every item", () => {
|
||||
var callbackCalled = 0;
|
||||
const result = Object.groupBy([1, 2, 3], () => {
|
||||
callbackCalled++;
|
||||
});
|
||||
expect(result.undefined).toEqual([1, 2, 3]);
|
||||
expect(callbackCalled).toBe(3);
|
||||
});
|
||||
});
|
Loading…
Add table
Add a link
Reference in a new issue