Skip to content

Commit

Permalink
test: spice up SelectionToolbar (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
stoffeastrom committed Dec 8, 2019
1 parent 4c01550 commit 20a91cd
Showing 1 changed file with 54 additions and 5 deletions.
59 changes: 54 additions & 5 deletions apis/nucleus/src/components/__tests__/selectiontoolbar.spec.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,60 @@ describe('<SelectionToolbarWithDefault />', () => {
expect(api.canConfirm.callCount).to.equal(1);
const types = renderer.root.findAllByType(IconButton);
expect(types).to.have.length(3);
types.forEach(t => {
t.props.onClick();
});
expect(api.clear.callCount).to.equal(1);
expect(api.cancel.callCount).to.equal(1);
});
it('should confirm', async () => {
const api = {
canClear: sandbox.stub(),
clear: sandbox.stub(),
canCancel: sandbox.stub(),
cancel: sandbox.stub(),
canConfirm: sandbox.stub(),
confirm: sandbox.stub(),
};
const onConfirm = sandbox.spy();
await render({}, api, [], undefined, onConfirm);
expect(api.canClear.callCount).to.equal(1);
expect(api.canCancel.callCount).to.equal(1);
expect(api.canConfirm.callCount).to.equal(1);
const confirm = renderer.root.findByProps({ title: 'Selection.Confirm' });
confirm.props.onClick();
expect(api.confirm.callCount).to.equal(1);
expect(onConfirm.callCount).to.equal(1);
});
it('should cancel', async () => {
const api = {
canClear: sandbox.stub(),
clear: sandbox.stub(),
canCancel: sandbox.stub(),
cancel: sandbox.stub(),
canConfirm: sandbox.stub(),
confirm: sandbox.stub(),
};
const onCancel = sandbox.spy();
await render({}, api, [], onCancel);
expect(api.canClear.callCount).to.equal(1);
expect(api.canCancel.callCount).to.equal(1);
expect(api.canConfirm.callCount).to.equal(1);
const confirm = renderer.root.findByProps({ title: 'Selection.Cancel' });
confirm.props.onClick();
expect(api.cancel.callCount).to.equal(1);
expect(onCancel.callCount).to.equal(1);
});
it('should clear', async () => {
const api = {
canClear: sandbox.stub(),
clear: sandbox.stub(),
canCancel: sandbox.stub(),
cancel: sandbox.stub(),
canConfirm: sandbox.stub(),
confirm: sandbox.stub(),
};
await render({}, api);
expect(api.canClear.callCount).to.equal(1);
expect(api.canCancel.callCount).to.equal(1);
expect(api.canConfirm.callCount).to.equal(1);
const confirm = renderer.root.findByProps({ title: 'Selection.Clear' });
confirm.props.onClick();
expect(api.clear.callCount).to.equal(1);
});
});

0 comments on commit 20a91cd

Please sign in to comment.