mardi 27 janvier 2015

Using an initializer in an unit test?

I have a stdlib initializer. In that initializer, i reopen some of built-in Ember classes and add some custom methods. For example, an Ember.Enumerable#reverseEach.


They work fine in the app, but in tests i receive "reverseEach: undefined is not a function".


How do i indicate that the test should use the initializer?


I tried needs: [..., 'initializer:stdlib']. It does not stumble upon that, but i still receive the "undefined" error.


Here's an example test:



`import { test, moduleForModel } from 'ember-qunit'`

moduleForModel 'foo', 'foo',
needs: [
'model:bar'
'initializer:stdlib'
]

test 'deleteLastNItems', ->
model = @subject()
model.set '', ['foo', 'bar', 'baz', 'quux']
model.deleteLastNItems 2 # This should not die with "reverseEach: undefined is not a function"
deepEquals model.get('someProperty'), ['foo', 'bar']




Aucun commentaire:

Enregistrer un commentaire