Skip to content

Commit

Permalink
Fix nuanced test irregularities
Browse files Browse the repository at this point in the history
Rename mistakenly named assignments, which were misleading.
Additionally, the reliance upon the default `value="left"` could lead to
a false-positive test. Changing to a none-default of `value="right"`
improves the validity of the test.
  • Loading branch information
dcalhoun committed Sep 28, 2021
1 parent e5cb098 commit bcd16d6
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@ import BlockAlignmentUI from '../ui';
it( 'should call onChange with undefined, when the control is already active', () => {
const onChangeMock = jest.fn();
const screen = render(
<BlockAlignmentUI value="left" onChange={ onChangeMock } />
<BlockAlignmentUI value="right" onChange={ onChangeMock } />
);
const alignButton = screen.getByA11yLabel( 'Align' );
fireEvent.press( alignButton );
const noneAlignmentButton = screen.getByA11yLabel( 'None' );
fireEvent.press( noneAlignmentButton );
const rightAlignmentButton = screen.getByA11yLabel( 'Align right' );
fireEvent.press( rightAlignmentButton );

expect( onChangeMock ).toHaveBeenCalledTimes( 1 );
expect( onChangeMock ).toHaveBeenCalledWith( undefined );
Expand All @@ -29,8 +29,8 @@ it( 'should call onChange with alignment value when the control is inactive', ()
);
const alignButton = screen.getByA11yLabel( 'Align' );
fireEvent.press( alignButton );
const noneAlignmentButton = screen.getByA11yLabel( 'Align center' );
fireEvent.press( noneAlignmentButton );
const centerAlignmentButton = screen.getByA11yLabel( 'Align center' );
fireEvent.press( centerAlignmentButton );

expect( onChangeMock ).toHaveBeenCalledTimes( 1 );
expect( onChangeMock ).toHaveBeenCalledWith( 'center' );
Expand Down

0 comments on commit bcd16d6

Please sign in to comment.