So I'm testing a component where I need it to act with my store to get the correct testable behavior. I've read that, since the "View" requires the store to function, I need to not mock the store, and also to not mock the "object-assign" thingy.
Excerpts from test code:
jest.dontMock('object-assign');
jest.dontMock('../StationSearch.jsx');
jest.dontMock('../../stores/StationStore.js');
describe('StationSearch', function() {
var StationSearch;
var stationSearch;
var React;
var TestUtils;
beforeEach(function() {
React = require('react/addons');
TestUtils = React.addons.TestUtils;
StationSearch = require('../StationSearch.jsx');
stationSearch = TestUtils.renderIntoDocument(<StationSearch />);
});
it('is rendered without value by default', function() {
// code here
}
);
And some code from the View:
var React = require('react');
var StationStore = require('../stores/StationStore');
var StationSearch = React.createClass({
componentDidMount: function() {
StationStore.addChangeListener(this._onChange);
},
});
Now, when running my tests, I get
TypeError: Cannot call method 'addChangeListener' of undefined
...on my change listener line, despite that I (think that I) am doing the right things when it comes to "not mocking" things.
Anyone has a clue as to why I could be getting this, still?