Skip to content

Kata 76 - Promise Creation - doesn't wrok in TDDbin #35

@rr326

Description

@rr326

I couldn't get the kata to resolve. So I checked out the original checkin (which should pass). Tests 2&3 don't work.

But pasting it into Chrome debugger, it works properly (as it should).

Test

  describe('extending a `Promise`', function() {
    it('is possible', function() {
      class MyPromise extends Promise {}
      const promise = new MyPromise(resolve => resolve());

      promise
        .then(() => done())
        .catch(e => done(new Error('Expected to resolve, but failed with: ' + e)));
    });
    it('must call `super()` in the constructor if it wants to inherit/specialize the behavior', function() {
      // WARNING: this example doesn't fulfill the Liskov principle
      class ResolvingPromise extends Promise {
        constructor() {
          super(resolve => resolve());
        }
      }

      return new ResolvingPromise();
    });
  });

Returns

extending a Promise
is possible ‣
TypeError: # is not a promise
at new MyPromise (eval at runSpecs (http://tddbin.com/mocha/spec-runner.js:95056:7), :28:81)
at eval (eval at runSpecs (http://tddbin.com/mocha/spec-runner.js:95056:7), :34:21)
at r (http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:9112)
at r.o.run (http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:9812)
at o.runTest (http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:13250)
at http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:13824
at r (http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:12787)
at http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:12763
at n (http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:12554)
at http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:12618
must call super() in the constructor if it wants to inherit/specialize the behavior ‣
TypeError: # is not a promise
at new ResolvingPromise (eval at runSpecs (http://tddbin.com/mocha/spec-runner.js:95056:7), :53:88)
at eval (eval at runSpecs (http://tddbin.com/mocha/spec-runner.js:95056:7), :61:14)
at r (http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:9112)
at r.o.run (http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:9812)
at o.runTest (http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:13250)
at http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:13824
at r (http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:12787)
at http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:12763
at n (http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:12554)
at http://cdnjs.cloudflare.com/ajax/libs/mocha/2.1.0/mocha.min.js:2:12618

In Chrome

done = (retval) => `done ${retval}`
(retval) => `done ${retval}`
      class MyPromise extends Promise {}
      const promise = new MyPromise(resolve => resolve());

      promise
        .then(() => done())
        .catch(e => done(new Error('Expected to resolve, but failed with: ' + e)));

Returns

Promise {[[PromiseStatus]]: "resolved", [[PromiseValue]]: "done undefined"}

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