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

Stop changing current object in plural assertions #134

@btd

Description

@btd

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions