Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Have promise rejection tests mirror how Chai tests exceptions. #167

Closed

Commits on Sep 15, 2016

  1. Added test cases to cover issue chaijs#47.

    The problem is that expect().to.be.rejected/rejectedWith (and its
    negation) does not mirror how expect().to.throw (and its negation)
    behave.
    
    Same issue with assert.isRejected in relation to assert.throws.
    lddubeau committed Sep 15, 2016
    Configuration menu
    Copy the full SHA
    56ea133 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    f06f849 View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    17d7dd8 View commit details
    Browse the repository at this point in the history
  4. Configuration menu
    Copy the full SHA
    cd4f4b9 View commit details
    Browse the repository at this point in the history
  5. Add a notMessage option.

    The problem with issue chaijs#47 is that chai-as-promised somtimes treats the
    final string parameter as a custom error message. We want to test that
    it does not do this anymore so we check to make sure that such string is
    not used as a custom error message.
    lddubeau committed Sep 15, 2016
    Configuration menu
    Copy the full SHA
    828c2d2 View commit details
    Browse the repository at this point in the history
  6. Allow chaining tests and promises.

    - `.fulfilled`, `.not.rejected` and `.not.rejectedWith` when successful:
    
      * The promise they return is fulfilled with the same value as the
        promise they were testing.
    
    - When `.not.fulfilled`, `.rejected` and `.rejectedWith` are successful:
    
      * The promise they return is fulfilled with the rejection
        reason.
    
    In all cases, when they fail, the promise they return is rejected and
    has for reason the assertion that failed.
    
    The changes above make it so that the `object` flag is automatically
    set when the promise returned is resolved, and thus also allows
    chaining.
    
    This fixes chaijs#113.
    lddubeau committed Sep 15, 2016
    Configuration menu
    Copy the full SHA
    1e629d3 View commit details
    Browse the repository at this point in the history
  7. Configuration menu
    Copy the full SHA
    79f12ac View commit details
    Browse the repository at this point in the history
  8. Use check-error to get expected constructor name.

    We now use the check-error package to get the constructor name of the
    error we expect to get with `rejectedWith`. For recent versions of Chai,
    this makes `rejectedWith` consistent in behavior with Chai's `throw`.
    
    Fixes chaijs#64.
    lddubeau committed Sep 15, 2016
    Configuration menu
    Copy the full SHA
    4656d67 View commit details
    Browse the repository at this point in the history
  9. Fix the .not.rejectedWith tests.

    In Chai `foo.should.not.throw(Constructor, 'string')` would fail only if
    the error thrown is an instance of `Constructor` **and** if its message
    includes `'string'`. An instance with a different message would not
    cause a failure. An instance constructed by something else than
    `Constructor` would not cause a failure.
    
    .not.rejectedWith's semantics were incompatible with the above.
    
    This commit fixes the test to work according to the correct semantics.
    lddubeau committed Sep 15, 2016
    Configuration menu
    Copy the full SHA
    150b666 View commit details
    Browse the repository at this point in the history
  10. Configuration menu
    Copy the full SHA
    ddc7bf7 View commit details
    Browse the repository at this point in the history

Commits on Sep 18, 2016

  1. Bring promise rejection tests in line with Chai.

    chai-as-promised's `.rejectedWith` and `assert.isRejected` now mirror
    how Chai's `.throws` works. Fixes issue chaijs#47.
    lddubeau committed Sep 18, 2016
    Configuration menu
    Copy the full SHA
    c6188f4 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    8f1fa2b View commit details
    Browse the repository at this point in the history