Skip to content

Commit

Permalink
[@mantine/tests] Add more descriptive assertion to it-supports-ref
Browse files Browse the repository at this point in the history
  • Loading branch information
rtivital committed Dec 4, 2021
1 parent c08d4bd commit 2f32905
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import React from 'react';
import { shallow } from 'enzyme';
import { itSupportsRef } from '@mantine/tests';
import { SelectDropdown } from './SelectDropdown';
import { Paper } from '../../Paper';

Expand All @@ -18,7 +17,6 @@ const defaultProps = {
};

describe('@mantine/core/SelectDropdown', () => {
itSupportsRef(SelectDropdown, defaultProps, HTMLDivElement);
it('sets correct id and aria-labelledby props on listbox', () => {
const props = shallow(<SelectDropdown {...defaultProps} />)
.find(Paper)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
import { itRendersChildren, itSupportsStyle, itSupportsOthers } from '@mantine/tests';
import {
itRendersChildren,
itSupportsStyle,
itSupportsOthers,
itSupportsRef,
mockResizeObserver,
} from '@mantine/tests';
import { SelectScrollArea } from './SelectScrollArea';

mockResizeObserver();

describe('@mantine/core/SelectScrollArea', () => {
itRendersChildren(SelectScrollArea, {});
itSupportsStyle(SelectScrollArea, {});
itSupportsOthers(SelectScrollArea, {});
itSupportsRef(SelectScrollArea, {}, HTMLDivElement);

it('has correct displayName', () => {
expect(SelectScrollArea.displayName).toEqual('@mantine/core/SelectScrollArea');
Expand Down
2 changes: 1 addition & 1 deletion src/mantine-tests/src/it-supports-ref.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,6 @@ export function itSupportsRef(
const ref = React.createRef<typeof refType>();
const element = mount(<Component {...requiredProps} {...{ [refProp]: ref }} />);
await waitForComponentToPaint(element);
expect(ref.current instanceof refType).toBe(true);
expect(ref.current?.constructor).toBe(refType);
});
}

0 comments on commit 2f32905

Please sign in to comment.