I have a simple object (in app/models/fruit.js
) that has a static method:
import Ember from 'ember';
const Fruit = Ember.Object.extend({
});
Fruit.reopenClass({
createFruit() {
}
}
export default Fruit;
and I have a test (in tests/unit/models/fruit-test.js
):
import Ember from 'ember';
import { moduleFor, test } from 'ember-qunit';
moduleFor('model:fruit', 'Unit | Model | fruit', {
});
test('has static method', function(assert) {
let model = this.subject();
assert.ok(model.createFruit);
});
this correctly fails because - as I understand it - the model
is an actual instance of my class, not the class itself.
This is mentioned in the testing docs:
Test helpers provide us with some conveniences, such as the subject function that handles lookup and instantiation for our object under test.
as well as theember-qunit
docs:
You do not have direct access to the component instance.
So how can I tests a class function/property instead of just instance methods/properties?
Aucun commentaire:
Enregistrer un commentaire