I am trying to test a mixin that is shared between two data components in my app.
This is my mixin, stripped down for simplicity:
define(
[],
function () {
'use strict';
function withDataCore() {
this.initializeWidget = function (ev, data) {
self.trigger('eventName');
self.off('someOtherEvent');
};
this.reinitializeWidget = function (ev, data) {
//Reinit method ...
};
}
return withDataCore;
}
);
And this is my test for that mixin:
define(
[],
function () {
'use strict';
describeMixin('mixins/core/withDataCore', function () {
var testData = {
beforeEach(function () {
this.setupComponent(testData);
});
describe('initializeWidget method - ', function () {
it('test', function () {
//given
var spy = spyOnEvent(this.component.node, 'eventName');
//when
this.component.initializeWidget();
expect(spy).toHaveBeenTriggeredOn('eventName');
});
});
describe('reinitializeWidget method - ', function () {
it('test', function () {
//given
spyOnEvent(this.component.node, 'eventName');
//when
this.component.reinitializeWidget();
//then
expect('eventName').toHaveBeenTriggeredOn(this.component.node);
});
});
});
}
);
When i run the test for only this mixin, everything is ok (using ddescribeMixin), but when i run all the test, including the tests for the components in which the mixin is mixed in, i get this error:
Chrome 39.0.2171 (Windows 8.1) mixins/core/withDataCore initializeWidget method - test FAILED
timeout: timed out after 5000 msec waiting for something to happen
When i comment out both of these components that are using this mixin and run all of the tests, again, everything is ok.
Does anybody have a clue what is going on here?
I would really appreciate your help.
Sorry for the long post. :)