karthikaruna
karthikaruna

Reputation: 3256

Ember: Mocking RecordArray

For acceptance tests of components that involve peekAll, I've stubbed the store service with the peekAll method that returns an array of Ember.Object, by which I'm able to retrieve the records and display.

But save, set and get methods aren't working, as peekAll in it's original form returns a RecordArray.

How do I return a RecordArray from the store stub?

Upvotes: 0

Views: 179

Answers (1)

LocalPCGuy
LocalPCGuy

Reputation: 6116

Instead of mocking the store service, it might be preferable to inject it, and then use createRecord to add your test record to the store. Then the peekAll will get a RecordArray as per usual, which will include all of the appropriate methods. Otherwise you end up going down a bit of a rabbithole creating more and more mock functions (for example, you could create save, set and get methods, and add them to your EmberObject, but what about the next function you need...).

Upvotes: 2

Related Questions