dimanche 17 avril 2016

Ember testing components that have helpers that use services

Say I have this inside a component:

{{#if (has-spotify)}}
  <i class="fa fa-spotify" data-toggle="modal" data-target="#myModal"></i>
{{else}}
  <i class="fa fa-spotify" {{action "authSpotify"}}></i>
{{/if}}

And the has-spotify helper has this:

import Ember from 'ember';

export function hasSpotify() {
  return this.get('spotifyService.spotifyInfo').then((result) =>{
    return result !== undefined;
  });
}

export default Ember.Helper.extend({
  spotifyService: Ember.inject.service(),
  compute: hasSpotify
});

And the spotifyService makes a call to our API.

How can I stub that helper inside the components test?




Aucun commentaire:

Enregistrer un commentaire