Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
mattzeunert committed Dec 7, 2018
1 parent 95000ab commit 43c6259
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions lighthouse-core/test/lib/client-rect-functions-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,32 +45,32 @@ describe('simplifyClientRects', () => {
containingRect,
]), [containingRect]);
});
it('Merges rects if a smaller rect is inside a larger one', () => {
it('Merges two horizontally adjacent client rects', () => {
const res = simplifyClientRects([
makeClientRect({
x: 10,
y: 10,
width: 50,
width: 100,
height: 10,
}),
makeClientRect({
x: 10,
x: 110,
y: 10,
width: 100,
height: 10,
}),

]);
assert.deepEqual(res, [
makeClientRect({
x: 10,
y: 10,
width: 100,
width: 200,
height: 10,
}),
]);
});
it('Merges two horizontally adjacent client rects', () => {

it('Merges three horizontally adjacent client rects', () => {
const res = simplifyClientRects([
makeClientRect({
x: 10,
Expand All @@ -84,43 +84,49 @@ describe('simplifyClientRects', () => {
width: 100,
height: 10,
}),
makeClientRect({
x: 210,
y: 10,
width: 100,
height: 10,
}),
]);
assert.deepEqual(res, [
makeClientRect({
x: 10,
y: 10,
width: 200,
width: 300,
height: 10,
}),
]);
});

it('Merges three horizontally adjacent client rects', () => {
it('Merges client rects correctly if one is duplicated', () => {
const res = simplifyClientRects([
makeClientRect({
x: 10,
y: 10,
width: 100,
width: 90,
height: 10,
}),
makeClientRect({
x: 110,
x: 10,
y: 10,
width: 100,
width: 90,
height: 10,
}),
makeClientRect({
x: 210,
x: 100,
y: 10,
width: 100,
width: 10,
height: 10,
}),
]);
assert.deepEqual(res, [
makeClientRect({
x: 10,
y: 10,
width: 300,
width: 100,
height: 10,
}),
]);
Expand Down

0 comments on commit 43c6259

Please sign in to comment.