Skip to content
This repository has been archived by the owner on Nov 4, 2020. It is now read-only.

Stop changing current object in plural assertions #134

Open
btd opened this issue Jan 27, 2017 · 0 comments
Open

Stop changing current object in plural assertions #134

btd opened this issue Jan 27, 2017 · 0 comments

Comments

@btd
Copy link
Member

btd commented Jan 27, 2017

In future version i would like to stop changing this.obj in assertions like .key or .property. I would like this assertion to save this plural object in addtional property, and if .which is called it will restore it. Examples:

  1. Current behaviour:
({ a: 42 }).should.have.key('a').and.be.Number();

As .key changed current object to be 42 (value of key 'a'), we can chain with a Number assertion.

  1. Proposed change:
({ a: 1, b: 2 }).should.have.key('a').and.key('b');
// this time given object is not changed, but
({ a: 1, b: 'a' }).should.have.key('b').which.is.a.String();
// .which restore last object from .keys to use in next assertions
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

1 participant