I have a mixin that helps me get through a workflow of steps. Basically it looks at what the current step is and then does some magic based on that. The issue is that the first line of the function grabs this.controllerFor('document')
and I don't understand how to mock that controllerFor
call. I know that I can, for example, pass {testing: "123"}
into the .create
in the test. This will then give me this.get('testing')
but how do I mock the controllerFor
? Also, to be clear, the only reason for the controllerFor call is so that I can get the currentStep
.
prepare-next.js
setNext: function() {
let currentStep = this.controllerFor('document').get('currentStep');
if (currentStep === 'First_step') {
//do something
} else {
//do something else...
}
// Bunch more stuff happens...
}
prepare-next-test.js
import Ember from 'ember';
import PrepareNext from 'my-app/mixins/prepare-next';
import { module, test } from 'qunit';
module('mixin:prepare-next');
const PrepareNextObject = Ember.Object.extend(PrepareNext);
let subject;
test('#setNext does all the things', function(assert) {
subject = PrepareNextObject.create();
subject.setNext();
//assert.equal(foo, bar);
});
Aucun commentaire:
Enregistrer un commentaire