I'm facing some problems figuring out how to pass a test in Ember.
The thing is, I'm trying to use NProgress in my project, but I can't pass my tests.
I'm following this example to create a mixing for it, and everything is working fine, besides the tests.
That's the mixing I created:
import Ember from 'ember';
NProgress.configure({ showSpinner: true });
export default Ember.Mixin.create({
actions: {
loading() {
if(!Ember.$('.nprogress-busy').length) {
if(Ember.$('#content').length) {
Ember.$('#content').removeClass('fadeIn');
Ember.$('#content').addClass('animated fadeOut');
}
if(Ember.$('#page-content-wrapper').length) {
Ember.$('#page-content-wrapper').removeClass('fadeIn');
Ember.$('#page-content-wrapper').addClass('animated fadeOut');
}
NProgress.start();
}
this.router.one('didTransition', function () {
window.scrollTo(0, 0);
setTimeout(function(){
if(Ember.$('#content').length) {
Ember.$('#content').removeClass('fadeOut');
Ember.$('#content').addClass('animated fadeIn');
}
if(Ember.$('#page-content-wrapper').length) {
Ember.$('#page-content-wrapper').removeClass('fadeOut');
Ember.$('#page-content-wrapper').addClass('animated fadeIn');
}
}, 1000);
NProgress.done();
return true;
});
},
error() {
NProgress.done();
return true;
}
}
});
And that's what is failing:
not ok 80 PhantomJS 2.0 - JSHint - mixins: mixins/loading-indicator.js should pass jshint
---
actual: >
false
expected: >
true
message: >
mixins/loading-indicator.js should pass jshint.
mixins/loading-indicator.js: line 2, col 1, 'NProgress' is not defined.
mixins/loading-indicator.js: line 16, col 11, 'NProgress' is not defined.
mixins/loading-indicator.js: line 30, col 11, 'NProgress' is not defined.
mixins/loading-indicator.js: line 35, col 9, 'NProgress' is not defined.
4 errors
Log: |
...
As you can see, I can use NProgress without any problems on the application, but as I'm not declaring NProgress anywhere the test fails.
Does anyone have an idea about how I could pass it?
I know there are similar components in ember, but I chose to use NProgress because I can set when I want it to start, and when I want it finish. I didn't want to use a progress bar where I would need to set a time for the animation.
Thanks in advance!
Aucun commentaire:
Enregistrer un commentaire