Skip to content
This repository has been archived by the owner on Oct 19, 2021. It is now read-only.

Commit

Permalink
test(ComposedModal): test selectorPrimaryFocus behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
emyarod committed Dec 12, 2018
1 parent db184d2 commit 368bf79
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions src/components/ComposedModal/ComposedModal-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -186,4 +186,27 @@ describe('<ComposedModal />', () => {
button.simulate('click');
expect(wrapper.state().open).toEqual(true);
});

it('should focus on the primary actionable button in ModalFooter by default', () => {
mount(
<ComposedModal open>
<ModalFooter primaryButtonText="Save" />
</ComposedModal>
);
expect(
document.activeElement.classList.contains('bx--btn--primary')
).toEqual(true);
});

it('should focus on the element that matches selectorPrimaryFocus', () => {
mount(
<ComposedModal open selectorPrimaryFocus=".bx--modal-close">
<ModalHeader label="Optional Label" title="Example" />
<ModalFooter primaryButtonText="Save" />
</ComposedModal>
);
expect(
document.activeElement.classList.contains('bx--modal-close')
).toEqual(true);
});
});

0 comments on commit 368bf79

Please sign in to comment.