Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('should have getAllByPlaceholderText', () => {
within(container).getAllByPlaceholderText('1');
});
it('should have getByTestId', () => {
within(container).getByTestId('1');
});
test('modal shows the children', () => {
render(
<div data-testid="test">
,
)
const {getByTestId} = within(document.getElementById('modal-root'))
expect(getByTestId('test')).toBeInTheDocument()
})
</div>
it('should have queryByAltText', () => {
within(container).queryByAltText('1');
});
it('should have queryByDisplayValue', () => {
within(container).queryByDisplayValue('1');
});
export function getQueries(container = document.body) {
return {
...within(container),
updateTextInput: updateTextInput.bind(null, container),
getButtonByText: getButtonByText.bind(null, container)
};
}
test('should render a sidebar if showSidebar is not set', () => {
const { getByTestId } = render(
);
const sidebar = within(getByTestId('sidebar'));
const links = sidebar.getAllByRole('link');
expect(links.map((node: any) => node.href)).toEqual([
'http://localhost/#foo',
'http://localhost/#bar',
]);
expect(links.map(node => node.textContent)).toEqual(['Foo', 'Bar']);
});
it('should display two confirm modals in chronological order if called twice', () => {
const { getAllByTestId } = render()
act(() => {
confirm(MESSAGE_1)
confirm(MESSAGE_2)
})
const notifications = getAllByTestId('confirm-modal-container')
expect(notifications).toHaveLength(2)
expect(
within(notifications[0]).getByTestId('confirm-modal-content').textContent
).toEqual(MESSAGE_1)
expect(
within(notifications[1]).getByTestId('confirm-modal-content').textContent
).toEqual(MESSAGE_2)
})
null}
triggerElement={
<button data-testid="drawer-trigger-element">show</button>
}
>
<div data-testid="content">CONTENT</div>
)
fireEvent.click(getByTestId('drawer-trigger-element'))
fireEvent.click(getByTestId('drawer-overlay'))
const modalContainer = queryByTestId('drawer-container') as HTMLElement
expect(modalContainer).toBeTruthy()
expect(within(modalContainer).queryByTestId('content')).toBeTruthy()
})
it('should not render if not opened once', () => {
(content, element) => content === 'button' && !!within(element).queryByText('Remove'),
);