hamjest 3.6.2 → 3.7.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -209,14 +209,12 @@ describe('IsObjectWithProperties', () => {
209
209
  });
210
210
 
211
211
  describe('hasDeepProperties', () => {
212
- function Person(name, partner) {
213
- this.name = name;
214
- this.partner = partner;
215
- }
216
-
217
- let sut;
218
- beforeEach(() => {
219
- sut = __.hasDeepProperties({
212
+ it('converts every sub-object to a hasDeepProperties matcher', () => {
213
+ function Person(name, partner) {
214
+ this.name = name;
215
+ this.partner = partner;
216
+ }
217
+ const sut = __.hasDeepProperties({
220
218
  name: 'Joe',
221
219
  partner: {
222
220
  name: __.startsWith('Jane'),
@@ -225,15 +223,32 @@ describe('IsObjectWithProperties', () => {
225
223
  }
226
224
  }
227
225
  });
228
- });
229
226
 
230
- it('converts every sub-object to a hasDeepProperties matcher', () => {
231
227
  __.assertThat(sut.matches(new Person('Joe', {name: 'Janette', pet: {name: 'Garfield'}})), __.is(true));
232
228
  __.assertThat(sut.matches(new Person('Joe', {name: 'Janette', pet: {name: 'Garfield', age: 52}})), __.is(true));
233
229
 
234
230
  __.assertThat(sut.matches(new Person('Joe', {name: 'Janette', pet: {name: 'John'}})), __.is(false));
235
231
  __.assertThat(sut.matches(new Person('Joe', {name: 'Abigail', pet: {name: 'Garfield'}})), __.is(false));
236
232
  });
233
+
234
+ it('converts every sub-array to a "contains(hasDeepProperties(), …)" matcher', () => {
235
+ function Person(name, children = []) {
236
+ this.name = name;
237
+ this.children = children;
238
+ }
239
+ const sut = __.hasDeepProperties({
240
+ name: 'Joe',
241
+ children: [
242
+ {name: 'Jane'},
243
+ {name: 'Jim'},
244
+ ],
245
+ });
246
+
247
+ __.assertThat(sut.matches(new Person('Joe', [new Person('Jane'), new Person('Jim')])), __.is(true));
248
+
249
+ __.assertThat(sut.matches(new Person('Joe')), __.is(false));
250
+ __.assertThat(sut.matches(new Person('Joe', [new Person('Jane')])), __.is(false));
251
+ });
237
252
  });
238
253
 
239
254
  describe('hasProperty', () => {