Skip to content

Commit

Permalink
add more zoom tests
Browse files Browse the repository at this point in the history
  • Loading branch information
chearon committed Oct 25, 2024
1 parent 8f1caf4 commit 3120a80
Showing 1 changed file with 51 additions and 0 deletions.
51 changes: 51 additions & 0 deletions test/flow.spec.js
Original file line number Diff line number Diff line change
@@ -1723,6 +1723,57 @@ describe('Flow', function () {
});

describe('Zoom', function () {
it('multiplies lengths on the box model', function () {
this.layout(`
<div id="t" style="float: left; zoom: 2;">
<div style="border: 2px solid; padding: 3px; margin: 4px; width: 5px; height: 5px;"></div>
</div>
`);

/** @type import('../src/layout-flow').BlockContainer */
const block = this.get('#t');
expect(block.contentArea.width).to.equal(46);
expect(block.contentArea.height).to.equal(46);
});

it('multiplies font-size and line-height', function () {
this.layout(`
<div style="font-size: 10px; zoom: 2;">
<div id="t1" style="line-height: 1;">sleepy</div>
<div id="t2" style="line-height: 20px;">ada</div>
</div>
`);

/** @type import('../src/layout-flow').BlockContainer */
const t1 = this.get('#t1');
expect(t1.contentArea.height).to.equal(20);
/** @type import('../src/layout-flow').BlockContainer */
const t2 = this.get('#t2');
expect(t2.contentArea.height).to.equal(40);
});

it('multiplies left and top', function () {
this.layout(`
<div style="position: relative; left: 10px; top: 10px; zoom: 250%;"></div>
`);

/** @type import('../src/layout-flow').BlockContainer */
const t = this.get('div');
expect(t.contentArea.x).to.equal(25);
expect(t.contentArea.y).to.equal(25);
});

it('multiplies bottom and right', function () {
this.layout(`
<div style="position: relative; right: 10px; bottom: 10px; zoom: 250%;"></div>
`);

/** @type import('../src/layout-flow').BlockContainer */
const t = this.get('div');
expect(t.contentArea.x).to.equal(-25);
expect(t.contentArea.y).to.equal(-25);
});

it('treats 0 as 100%', function () {
this.layout('<div style="zoom: 0; margin-left: 1px;"></div>');

0 comments on commit 3120a80

Please sign in to comment.