mercredi 9 décembre 2015

How to test if Ember.$.getJSON has the right URL in Ember?

I'm new to Ember and I'm not sure if there's a library to do this already. I have a route which gets data from a URL. I'm trying to unit test this model by checking if it's getting the right URL.

Here's my code.

export default SuperRoute.extend({
  controllerName: 'controller',

  model (params) {
    let url = 'url';
    return Ember.$.getJSON(url);
  }
});

And this is my test so far.

moduleFor('route:route', 'Unit: route');

test('sets controller name', function (assert) {
  let route = this.subject();
  assert.equal(route.controllerName, 'controller');
});

test('fetches the right url', function(assert) {
  let route = this.subject();
  route.model();
});

Not sure if Ember has mocking helper to check that already?




Aucun commentaire:

Enregistrer un commentaire