Skip to content

Commit

Permalink
Fix node 18.16.0 tests
Browse files Browse the repository at this point in the history
issue due to nodejs/node#47563

Change-type: patch
  • Loading branch information
JSReds committed Apr 20, 2023
1 parent 7887b18 commit 9c8097f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
9 changes: 6 additions & 3 deletions scripts/setupTests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ function copyProps(src: object, target: Record<string, any>) {
);
}

// @ts-expect-error
global.window = $window;
global.document = $window.document;
global = {
...global,
// @ts-expect-error
window: $window,
document: $window.document,
};

// See https://github.com/jsdom/jsdom/issues/3002 why we need to mock this.
global.document.createRange = () => {
Expand Down
7 changes: 2 additions & 5 deletions src/components/Notifications/spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -94,24 +94,21 @@ describe('Notifications component', () => {
expect(callback.callCount).toEqual(1);
});

it('disappears after the duration passes', () => {
it('disappears after the duration passes', async () => {
const component = mount(
<NotificationsComponent
content={{ content: 'A notification', duration: 20 }}
/>,
);
const clock = sinon.useFakeTimers();

component.find('button').first().simulate('click');

// On the first transitionend (on entry), it creates the timer, and on the second one (on exit), it removes the element from the DOM.
component.find('.rnc__notification-item').first().simulate('transitionend');
clock.tick(200);
await new Promise((r) => setTimeout(r, 200));
component.find('.rnc__notification-item').first().simulate('transitionend');

expect(component.find('.rnc__notification-item')).toHaveLength(0);

clock.restore();
});

it('displays notifications in the expected position', () => {
Expand Down

0 comments on commit 9c8097f

Please sign in to comment.