Closed mjhm closed 7 years ago
this bug confirmed.
matchPattern([{}, 1], [{},'...'])
'Array [ {}, 1 ] isn\'t a subset match of Array [ {} ]'
It should treat the array as object to match.
@snowyu Thanks -- I'm going to have to fix this.
Fixed https://github.com/Originate/lodash-match-pattern/releases/tag/v1.3.1
This now does deep matching of explicit subset, superset, equalset values, though it still doesn't allow matching functions in set elements. Such corner cases are probably too complicated to be implemented in this library.
I've solved my problem by getting every object at the set and using "matching functions" to compare every object.
Like the function below:
function successArray(res, status, objectToCompare) { chai.expect(res) .to.have.status(status); chai.expect(res.body) .is.an('array'); res.body.forEach(function(entry) { chai.expect(entry).to.matchPattern(objectToCompare); });
Results in error string
This should either be allowed or a more instructive error message.