Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gparlakov/3fac7f2a07f6c49448fc0c559eb1685f to your computer and use it in GitHub Desktop.
Save gparlakov/3fac7f2a07f6c49448fc0c559eb1685f to your computer and use it in GitHub Desktop.
it('when clicked on the second point should NOT navigate to show the selected point if it is NOT visible', () => {
// arrange
const r = mockRouter();
// arrange the onclick prerequisites
const ch = jasmine.createSpy('chart builder');
let onClickCallback: Function = () => {};
ch.and.callFake((i, o) => {
onClickCallback = o.options.onClick;
return {
// mock the isVisible method
getDataVisibility: jasmine
.createSpy('isVisibleMockMethod')
.and.returnValue(false),
};
});
const c = new ChartComponent(r, ch);
c.canvas = new ElementRef(document.createElement('canvas'));
c.ngAfterViewInit();
// act
onClickCallback(null, [{ index: 1 }]);
// assert
expect(r.navigate).not.toHaveBeenCalledWith([2]);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment