}));
};
- handleSymbolClick = (highlightedSymbols: string[]) => {
- this.setState({ highlightedSymbols });
+ handleSymbolClick = (clickedSymbols: string[]) => {
+ this.setState(({ highlightedSymbols }) => {
+ const newHighlightedSymbols = clickedSymbols.filter(
+ symb => !highlightedSymbols.includes(symb)
+ );
+ return { highlightedSymbols: newHighlightedSymbols };
+ });
};
loadDuplications = (line: T.SourceLine) => {
expect(wrapper.state('highlightedSymbols')).toEqual([]);
wrapper.instance().handleSymbolClick(['foo']);
expect(wrapper.state('highlightedSymbols')).toEqual(['foo']);
+ wrapper.instance().handleSymbolClick(['foo']);
+ expect(wrapper.state('highlightedSymbols')).toEqual([]);
});
it('should correctly handle lines actions', () => {