I have few Ember.Mixin
in my app that contains DS.attr()
and / or DS.belongsTo()
. I was wondering how should I unit test them ?
By default, ember-cli generate this test
test('it works', function(assert) {
var MyModelObject = Ember.Object.extend(MyModelMixin);
var subject = MyModelObject.create();
assert.ok(subject);
});
But when I tried to interact with an DS.attr()
I got the following error:
TypeError: Cannot read property '_attributes' of undefined
at hasValue (http://localhost:4200/assets/vendor.js:90650:25)
at Class.get (http://localhost:4200/assets/vendor.js:90730:13)
at Descriptor.ComputedPropertyPrototype.get (http://localhost:4200/assets/vendor.js:29706:28)
at Object.get (http://localhost:4200/assets/vendor.js:35358:19)
at Class.get (http://localhost:4200/assets/vendor.js:49734:38)
at Object.<anonymous> (http://localhost:4200/assets/tests.js:20126:25)
at runTest (http://localhost:4200/assets/test-support.js:2779:28)
at Object.run (http://localhost:4200/assets/test-support.js:2764:4)
at http://localhost:4200/assets/test-support.js:2906:11
at process (http://localhost:4200/assets/test-support.js:2565:24)
Which make senses. What is the best way to do it ? Should I create a DS.Model
within the test and then apply the mixin on it ?
Thanks !
Aucun commentaire:
Enregistrer un commentaire