Skip to content

Custom matcher for promises #181

@sbycrosz

Description

@sbycrosz

Context: I'm testing a Promise created using PromiseKit

What I have now:

promise.then(^(id result){
                            expect(result).to.equal(expected);
                        }).catch(^(NSError *error){ 
                            failure(error);
                        }).finally(^(){
                            done();
                        });

which the lazy old me use as a macro

#define AssertPromise(promise, expected) promise.then(^(id result){ expect(result).to.equal(expected);}).catch(^(NSError *error){ failure(error);}).finally(^(){done();});

What I wanted (similar library in JS: https://github.com/domenic/chai-as-promised/):

expect(promise).to.be.resolvedAs(expected)

Currently I am stuck on implementing the match method of EXPMatcher since it expects a boolean, but then we need to wait until the promise get resolved.

Would this kind of api be possible? Any kind of direction would be nice :)

Cheers,

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions