Skip to content

Commit

Permalink
change tests
Browse files Browse the repository at this point in the history
  • Loading branch information
vonagam committed Feb 6, 2019
1 parent f40974d commit f28d7fd
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
8 changes: 6 additions & 2 deletions test/object.js
Original file line number Diff line number Diff line change
Expand Up @@ -437,8 +437,12 @@ describe('Object types', () => {
}),
});

reach(inst, 'nested').should.equal(inst.fields.nested);
reach(inst, 'x.y').should.equal(inst.fields.x.fields.y);
reach(inst, 'nested')
.resolve({})
.should.equal(inst);
reach(inst, 'x.y')
.resolve({})
.should.equal(inst);
});

it('should be passed the value', done => {
Expand Down
32 changes: 25 additions & 7 deletions test/yup.js
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,33 @@ describe('Yup', function() {
},
};

// reach(inst, 'nested.arr.num', value).should.equal(num);
// reach(inst, 'nested.arr[].num', value).should.equal(num);

// reach(inst, 'nested.arr.num', value, context).should.equal(num);
// reach(inst, 'nested.arr[].num', value, context).should.equal(num);
// reach(inst, 'nested.arr[0].num', value, context).should.equal(num);
let options = {};
options.parent = value.nested.arr[0];
options.value = options.parent.num;
reach(inst, 'nested.arr.num', value)
.resolve(options)
.should.equal(num);
reach(inst, 'nested.arr[].num', value)
.resolve(options)
.should.equal(num);

options.context = context;
reach(inst, 'nested.arr.num', value, context)
.resolve(options)
.should.equal(num);
reach(inst, 'nested.arr[].num', value, context)
.resolve(options)
.should.equal(num);
reach(inst, 'nested.arr[0].num', value, context)
.resolve(options)
.should.equal(num);

// // should fail b/c item[1] is used to resolve the schema
// reach(inst, 'nested["arr"][1].num', value, context).should.not.equal(num);
options.parent = value.nested.arr[1];
options.value = options.parent.num;
reach(inst, 'nested["arr"][1].num', value, context)
.resolve(options)
.should.not.equal(num);

let reached = reach(inst, 'nested.arr[].num', value, context);

Expand Down

0 comments on commit f28d7fd

Please sign in to comment.