Skip to content

Commit

Permalink
chore: [#1408] Improves unit tests for DOMRectReadOnly and DOMRect
Browse files Browse the repository at this point in the history
  • Loading branch information
btea committed May 6, 2024
1 parent 48189ab commit 7a5b003
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 8 deletions.
3 changes: 2 additions & 1 deletion packages/happy-dom/src/nodes/element/DOMRect.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import DOMRectReadOnly, { IDOMRectInit } from './DOMRectReadOnly.js';
import DOMRectReadOnly from './DOMRectReadOnly.js';
import * as PropertySymbol from '../../PropertySymbol.js';
import IDOMRectInit from './IDOMRectInit.js';

/* eslint-disable jsdoc/require-jsdoc */

Expand Down
8 changes: 1 addition & 7 deletions packages/happy-dom/src/nodes/element/DOMRectReadOnly.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import * as PropertySymbol from '../../PropertySymbol.js';
import IDOMRectInit from './IDOMRectInit.js';

/* eslint-disable jsdoc/require-jsdoc */

Expand Down Expand Up @@ -77,10 +78,3 @@ export default class DOMRectReadOnly implements IDOMRectInit {
return new DOMRectReadOnly(other.x, other.y, other.width, other.height);
}
}

export interface IDOMRectInit {
readonly x: number;
readonly y: number;
readonly width: number;
readonly height: number;
}
6 changes: 6 additions & 0 deletions packages/happy-dom/src/nodes/element/IDOMRectInit.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
export default interface IDOMRectInit {
readonly x: number;
readonly y: number;
readonly width: number;
readonly height: number;
}
8 changes: 8 additions & 0 deletions packages/happy-dom/test/nodes/element/DOMRectReadOnly.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ describe('DOMRectReadOnly', () => {
expect(rect.y).toBe(2);
expect(rect.width).toBe(3);
expect(rect.height).toBe(4);
expect(rect.top).toBe(2);
expect(rect.right).toBe(4);
expect(rect.bottom).toBe(6);
expect(rect.left).toBe(1);

const rect2 = new DOMRectReadOnly(null, null, null, 4);
expect(rect2.x).toBe(0);
Expand Down Expand Up @@ -103,6 +107,10 @@ describe('DOMRectReadOnly', () => {
expect(rect.y).toBe(2);
expect(rect.width).toBe(3);
expect(rect.height).toBe(4);
expect(rect.top).toBe(2);
expect(rect.right).toBe(4);
expect(rect.bottom).toBe(6);
expect(rect.left).toBe(1);
});
});

Expand Down

0 comments on commit 7a5b003

Please sign in to comment.