Nie mogę uzyskać haków modelu i akcji wywołanych testem jednostkowym.Jak testować urządzenie Trasy w aplikacji ember-cli za pomocą qunit?
Każda próbka/blog robiący to środowisko ember-cli byłby bardzo pomocny!
I znaleziono link What kind of unit test solution for the routes in Ember.js?
ale route.model() jest generowania błędów, jak: przejściowa nie jest zdefiniowana.
import { test, moduleFor } from 'ember-qunit';
moduleFor('route:sample', 'SampleRoute', {
// Specify the other units that are required for this test.
});
test("beforeModel hook works", function(){
var route = this.subject();
Ember.run(function(){
route.set("model", "Sample data");
})
console.log("Model set. Was beforeModel hook called?");
});
Trasa Próbka
import Ember from 'ember';
export default Ember.Route.extend({
beforeModel: function (transition) {
console.log("Inside before-model hook");
},
afterModel: function() {
console.log("In after-model hook");
}
});
Czy mógłbyś dodać tutaj swój kod testowy? –
@PatsyIssa haki modelu nie są wyzwalane w testach. – Stuarty