Skip to content

Instantly share code, notes, and snippets.

@gparlakov
Last active May 22, 2022 17:11
Show Gist options
  • Save gparlakov/dc7ec2b7ff84dcd7f1c58614a1a3a5fd to your computer and use it in GitHub Desktop.
Save gparlakov/dc7ec2b7ff84dcd7f1c58614a1a3a5fd to your computer and use it in GitHub Desktop.
describe('test my chart', () => {
it('should draw the chart on ngAfterViewInit', () => {
// arrange
const c = setup().build();
// act
c.ngAfterViewInit();
// assert
expect(c.chart).toBeDefined();
});
it('when clicked on the second point should navigate to show the selected point if it is visible', () => {
// arrange
const { build, callOnClickWith, router } = setup().withChartGetDataVisibilityReturning(true);
const c = build();
c.ngAfterViewInit();
// act
callOnClickWith(1);
// assert
expect(router.navigate).toHaveBeenCalledWith([2]);
});
it('when clicked on the second point should NOT navigate to show the selected point if it is NOT visible', () => {
// arrange
const { build, callOnClickWith, router } =
setup().withChartGetDataVisibilityReturning(false);
const c = build();
c.ngAfterViewInit();
// act
callOnClickWith(1);
// assert
expect(router.navigate).not.toHaveBeenCalledWith([2]);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment