Skip to content

Commit

Permalink
chore(content-explorer): keep changes depended by other elements
Browse files Browse the repository at this point in the history
  • Loading branch information
tjiang-box committed Oct 8, 2024
1 parent 95c6a12 commit c08db4b
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
14 changes: 14 additions & 0 deletions scripts/jest/jest-setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,20 @@
import '@testing-library/jest-dom';
import util from 'util';

Object.defineProperty(window, 'matchMedia', {
writable: true,
value: jest.fn().mockImplementation(query => ({
matches: false,
media: query,
onchange: null,
addListener: jest.fn(), // Deprecated
removeListener: jest.fn(), // Deprecated
addEventListener: jest.fn(),
removeEventListener: jest.fn(),
dispatchEvent: jest.fn(),
})),
});

global.setImmediate = cb => {
setTimeout(cb, 0);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ export const openRenameDialog = {
expect(renameButton).toBeInTheDocument();
await userEvent.click(renameButton);

expect(await screen.findByText('Rename File')).toBeInTheDocument();
expect(await screen.findByText('Please enter a new name for Book Sample:')).toBeInTheDocument();
},
};

Expand All @@ -97,12 +97,12 @@ export const closeRenameDialog = {
expect(renameButton).toBeInTheDocument();
await userEvent.click(renameButton);

expect(await screen.findByText('Rename File')).toBeInTheDocument();
expect(await screen.findByText('Please enter a new name for Book Sample:')).toBeInTheDocument();
const cancelButton = screen.getByText('Cancel');
await userEvent.click(cancelButton);

await waitFor(() => {
expect(screen.queryByText('Rename File')).not.toBeInTheDocument();
expect(screen.queryByText('Please enter a new name for Book Sample:')).not.toBeInTheDocument();
});
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils/storybook.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// eslint-disable-next-line import/prefer-default-export
export const addRootElement = () => {
let appElement = document.getElementById('rootElement');
let appElement = document.getElementById('appElement');
let rootElement = document.getElementById('rootElement');

if (document.body && rootElement === null) {
Expand Down

0 comments on commit c08db4b

Please sign in to comment.