Skip to content

checking array elements #5

Description

@oprogramador
// this fails:
expect([{ foo: 123 }, { foo: 456 }]).to.matchPattern([{ foo: _.isNumber }]);

// this passes:
expect([{ foo: 123 }, { foo: 456 }]).to.matchPattern(x => x.length > 0 && x.map(y => expect(y).to.matchPattern({ foo: _.isNumber })));

What do you think about making the first expectation passing?

And it would be good to have a simpler way to write the second expectation (the additional check is length above 0).

Maybe the interface could be similar to Joi.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions