Skip to content

Commit 7132bb3

Browse files
committed
Update sinon spy tests
Use the BDD syntax from sinon-chai.
1 parent 562b3ae commit 7132bb3

File tree

3 files changed

+12
-12
lines changed

3 files changed

+12
-12
lines changed

app/classifier/tasks/components/TaskInputField/TaskInputField.spec.jsx

+8-8
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ import sinon from 'sinon';
1212
import { TaskInputField, StyledTaskInputField } from './TaskInputField';
1313
import { mockReduxStore, radioTypeAnnotation } from '../../testHelpers';
1414

15-
describe('TaskInputField', function() {
16-
describe('render', function() {
15+
describe('TaskInputField', function () {
16+
describe('render', function () {
1717
let wrapper;
1818
before(function () {
1919
wrapper = mount(<TaskInputField annotation={radioTypeAnnotation} index={0} type="radio" />, mockReduxStore);
@@ -39,24 +39,24 @@ describe('TaskInputField', function() {
3939
wrapper.setProps({ className: 'active' });
4040
expect(wrapper.props().className).to.include('active');
4141
});
42-
})
42+
});
4343

4444

45-
describe('onChange method', function() {
45+
describe('onChange method', function () {
4646
let onChangePropsSpy;
4747
let wrapper;
48-
before(function() {
48+
before(function () {
4949
onChangePropsSpy = sinon.spy();
5050
wrapper = mount(<TaskInputField annotation={radioTypeAnnotation} onChange={onChangePropsSpy} index={0} type="radio" />, mockReduxStore);
5151
});
5252

53-
afterEach(function() {
53+
afterEach(function () {
5454
onChangePropsSpy.resetHistory();
5555
});
5656

57-
it('should call onChange when the on change event is fired', function() {
57+
it('should call onChange when the on change event is fired', function () {
5858
wrapper.find('input').simulate('change');
59-
expect(onChangePropsSpy.calledOnce).to.be.true;
59+
expect(onChangePropsSpy).to.have.been.calledOnce;
6060
});
6161
});
6262
});

app/classifier/tasks/multiple/index.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ describe('MultipleChoiceTask', function () {
7171
it('should call props.onChange when an answer changes', function () {
7272
const firstAnswer = wrapper.find(GenericTask).prop('answers')[0];
7373
firstAnswer.props.onChange({ target: { checked: true } });
74-
expect(onChangeSpy.calledOnce).to.be.true;
74+
expect(onChangeSpy).to.have.been.calledOnce;
7575
});
7676

7777
it('should call handleChange with the answer array index', function() {
7878
wrapper.setProps({ annotation });
7979
const firstAnswer = wrapper.find(GenericTask).prop('answers')[0];
8080
firstAnswer.props.onChange({ target: { checked: true } });
81-
expect(handleChangeSpy.calledWith(0)).to.be.true;
81+
expect(handleChangeSpy).to.have.been.calledWith(0);
8282
});
8383
});
8484

app/classifier/tasks/single/index.spec.js

+2-2
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,13 @@ describe('SingleChoiceTask', function () {
7070
it('should call handleChange with the answer array index', function () {
7171
const firstAnswer = wrapper.find(GenericTask).prop('answers')[0];
7272
firstAnswer.props.onChange({ target: { checked: true } });
73-
expect(handleChangeSpy.calledWith(0)).to.be.true;
73+
expect(handleChangeSpy).to.have.been.calledWith(0);
7474
});
7575

7676
it('should call props.onChange when an answer changes and the target is checked', function () {
7777
const firstAnswer = wrapper.find(GenericTask).prop('answers')[0];
7878
firstAnswer.props.onChange({ target: { checked: true } });
79-
expect(onChangeSpy.calledOnce).to.be.true;
79+
expect(onChangeSpy).to.have.been.calledOnce;
8080
});
8181
});
8282

0 commit comments

Comments
 (0)