Skip to content

Commit 224f14b

Browse files
author
Walker Leite
committed
feat(methods): add propertyOfType assertion
1 parent 847d802 commit 224f14b

File tree

4 files changed

+36
-0
lines changed

4 files changed

+36
-0
lines changed

src/methods/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
export * from './have-many';
2+
export * from './property-of-type';

src/methods/index.spec.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,8 @@ describe('methods', () => {
44
it('export haveMany', () => {
55
expect(methods).toHaveProperty('haveMany');
66
});
7+
8+
it('export propertyOfType', () => {
9+
expect(methods).toHaveProperty('propertyOfType');
10+
});
711
});

src/methods/property-of-type.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
export function propertyOfType() {
2+
3+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import chai from 'chai';
2+
import loopbackChai from '../index';
3+
4+
describe('propertyOfType assertion', () => {
5+
// const perfecMock = {
6+
// properties: {
7+
// foo: {
8+
// type: 'string',
9+
// },
10+
// },
11+
// };
12+
13+
chai.use(loopbackChai);
14+
15+
function propertyOfType(subject, ...args) {
16+
return () => chai
17+
.expect(subject)
18+
.to
19+
.propertyOfType(...args);
20+
}
21+
22+
it('throws if wrong type', () => {
23+
const subj = {
24+
properties: { foo: { type: 'INVALID' } },
25+
};
26+
expect(propertyOfType(subj)).toThrow();
27+
});
28+
});

0 commit comments

Comments
 (0)