Created
November 23, 2014 02:55
-
-
Save ksin/302a6cfafe10295a759b to your computer and use it in GitHub Desktop.
api helper
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
var FakeClientApi = Ember.Object.extend({ | |
recentMediaForTagStub: null, | |
stubRecentMediaForTag: function(callback){ | |
this.recentMediaForTagStub = callback; | |
}, | |
recentMediaForTag: function(tag, options) { | |
if (this.recentMediaForTagStub) { | |
var results = this.recentMediaForTagStub.call(this, tag, options); | |
return Ember.RSVP.resolve(results); | |
} | |
return Ember.RSVP.reject('No stubs registered for recentMediaForTag. Did you forget to call `stubRecentMediaForTag`?'); | |
} | |
}); | |
export function apiStub(registryEntryName, app, dsl) { | |
var apiClient = FakeClientApi.create(); | |
app.register(registryEntryName, apiClient, { instantiate: false }); | |
dsl.call(apiClient); | |
return apiClient; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment