Skip to content

Commit 0653308

Browse files
author
Walker Leite
committed
fix(methods): makes haveMany params model and foreignKey required
1 parent 39cd8a9 commit 0653308

File tree

2 files changed

+16
-8
lines changed

2 files changed

+16
-8
lines changed

src/methods.js

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ export function haveMany(relationship, model, foreignKey) {
1010

1111
expect(relObj).to.haveOwnProperty('model');
1212
expect(relObj.model).to.not.empty;
13-
if (model) {
14-
expect(relObj.model).to.equal(model);
15-
}
13+
expect(relObj.model).to.equal(model);
1614

1715
expect(relObj).to.haveOwnProperty('foreignKey');
1816
expect(relObj.foreignKey).to.not.empty;
19-
if (foreignKey) {
20-
expect(relObj.foreignKey).to.equal(foreignKey);
21-
}
17+
expect(relObj.foreignKey).to.equal(foreignKey);
2218
}

src/methods.spec.js

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,23 @@ describe('haveMany assertion', () => {
6666
expect(hasMany({ balls: '' }, 'balls')).toThrow();
6767
});
6868

69+
it('throws if missing arguments', () => {
70+
expect(hasMany(
71+
perfectRelMock,
72+
'balls',
73+
perfectRelMock.balls.model,
74+
)).toThrow();
75+
expect(hasMany(
76+
perfectRelMock,
77+
'balls',
78+
)).toThrow();
79+
expect(hasMany(perfectRelMock)).toThrow();
80+
expect(hasMany()).toThrow();
81+
});
82+
6983
it('assert haveMany relationship', () => {
7084
const subj = perfectRelMock;
7185
const { model, foreignKey } = perfectRelMock.balls;
72-
expect(hasMany(subj, 'balls')).not.toThrow();
73-
expect(hasMany(subj, 'balls', model)).not.toThrow();
7486
expect(hasMany(subj, 'balls', model, foreignKey)).not.toThrow();
7587
});
7688
});

0 commit comments

Comments
 (0)