Commit c3b35367 authored by Kushal Pandya's avatar Kushal Pandya

Merge branch 'ph/fixshowBlobInteractionZonesThrowingError' into 'master'

Fix showBlobInteractionZones throwing an error when no data exists

See merge request gitlab-org/gitlab!31330
parents 1d52d207 7c763a5b
......@@ -30,7 +30,9 @@ export default {
});
},
showBlobInteractionZones({ state }, path) {
Object.values(state.data[path]).forEach(d => addInteractionClass(path, d));
if (state.data && state.data[path]) {
Object.values(state.data[path]).forEach(d => addInteractionClass(path, d));
}
},
showDefinition({ commit, state }, { target: el }) {
let definition;
......
......@@ -143,6 +143,16 @@ describe('Code navigation actions', () => {
expect(addInteractionClass.mock.calls[0]).toEqual(['index.js', 'test']);
expect(addInteractionClass.mock.calls[1]).toEqual(['index.js', 'console.log']);
});
it('does not call addInteractionClass when no data exists', () => {
const state = {
data: null,
};
actions.showBlobInteractionZones({ state }, 'index.js');
expect(addInteractionClass).not.toHaveBeenCalled();
});
});
describe('showDefinition', () => {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment