My class has the following constructor:
constructor() {
super();
this.togglePlay = this.togglePlay.bind(this);
this.toggleMute = this.toggleMute.bind(this);
this.toggleMaximize = this.toggleMaximize.bind(this);
this.state = {
play: false,
mute: false,
maximize: false,
actions: {
togglePlay: this.togglePlay,
toggleMute: this.toggleMute,
toggleMaximize: this.toggleMaximize
}
};
}
In my test, I want to compare the state...
it('should have the correct state', () => {
const wrapper = shallow(<Provider {...minProps} />);
const expectedState = {
play: false,
mute: false,
maximize: false,
actions: {
togglePlay: () => {},
toggleMute: () => {},
toggleMaximize: () => {}
}
};
const actualState = wrapper.state();
expect(expectedState).toEqual(actualState);
});
When running the test, I receive the following error:
Expected value to equal:
{"actions": {"toggleMaximize": [Function bound toggleMaximize], "toggleMute": [Function bound toggleMute], "togglePlay": [Function bound togglePlay]}, "maximize": false, "mute": false, "play": false}
Received:
{"actions": {"toggleMaximize": [Function toggleMaximize], "toggleMute": [Function toggleMute], "togglePlay": [Function togglePlay]}, "maximize": false, "mute": false, "play": false}
The test fails due to the function comparisons. How can I get this test to pass?