Closed saulshanabrook closed 9 years ago
Hey,
You could do that via any regular way you handle promises. Like:
promise.then((p) => JSON.parse(p.field)).must.then.eql({name: "John"})
Would that work?
Yep! I would also have to handle if the promise failed, right?
Not necessarily. If you pass the whole promise to something that waits on it, it'll blow up if your JSON parsing failed. Must uses the same mechanism — it just rejects the promise if the assertion failed. I wrote a small example here: https://github.com/moll/js-must/issues/22#issuecomment-111840555
Awesome, thank you!
Yippie!
Is it currently possible to change the data midway through an assertion?
For example I have a want to resolve a promise (using
eventually
) then select thevalue
key from the object returned, then convert that JSON string into a JS object, then do a check on it.