Skip to content

Commit

Permalink
fix test leak (#97082)
Browse files Browse the repository at this point in the history
  • Loading branch information
flash1293 authored Apr 15, 2021
1 parent e675429 commit 6c07eb2
Showing 1 changed file with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,19 @@ describe('LineClamp', () => {
describe('overflow', () => {
const clientHeight = 400;
const scrollHeight = clientHeight + 100; // scrollHeight is > clientHeight
let spyClientHeight: jest.SpyInstance<number, []>;
let spyScrollHeight: jest.SpyInstance<number, []>;

beforeAll(() => {
Object.defineProperty(HTMLElement.prototype, 'clientHeight', {
configurable: true,
value: clientHeight,
});
spyClientHeight = jest.spyOn(window.HTMLElement.prototype, 'clientHeight', 'get');
spyClientHeight.mockReturnValue(clientHeight);
spyScrollHeight = jest.spyOn(window.HTMLElement.prototype, 'scrollHeight', 'get');
spyScrollHeight.mockReturnValue(scrollHeight);
});

Object.defineProperty(HTMLElement.prototype, 'scrollHeight', {
configurable: true,
value: scrollHeight,
});
afterAll(() => {
spyClientHeight.mockRestore();
spyScrollHeight.mockRestore();
});

test('it does NOT render the expanded line clamp by default when isOverflow is true', () => {
Expand Down

0 comments on commit 6c07eb2

Please sign in to comment.