ember.jsember-qunit

EmberJs-How to reject an Ember.RSVP.Promise in qunit Unit TEST?


var stubMyService=Ember.Object.extend({
        //'authenticator:ooion( OAuth,username, password)
        authenticate(OAuth2,username,password)
         {
           return new Ember.RSVP.Promise(function(reject){
               Ember.run(null,reject,obj);
           });
          }
      });

Solution

  • Callback to RSVP.Promise accepts 2 arguments - resolve, and reject.

    return new Ember.RSVP.Promise(function(resolve, reject) {
        Ember.run(null, reject, obj);
    });
    

    Or, in ES2017 syntax:

    return new Ember.RSVP.Promise((resolve, reject) => Ember.run(null, reject, obj));