Last active
May 18, 2022 18:55
-
-
Save gparlakov/e62d171d04e59723edde4f325be62354 to your computer and use it in GitHub Desktop.
test-chart-js.chart-builder-called-chart-constructed.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
it('should draw the chart on ngAfterViewInit with canvas and config', () => { | |
// arrange | |
const r = mockRouter(); | |
const builderSpy = jasmine.createSpy('chart builder') | |
builderSpy.and.returnValue('the chart'); | |
const c = new ChartComponent(r, builderSpy); | |
const canvas = document.createElement('canvas'); | |
c.canvas = new ElementRef(canvas); | |
// act | |
c.ngAfterViewInit(); | |
// assert | |
expect(ch).toHaveBeenCalledOnceWith(canvas, jasmine.objectContaining({ | |
type: 'line', | |
data: { | |
datasets: [{ [1,2,3,4,5], label: '1' }], | |
labels: ['1', '2', '3', '4', '5'], | |
} | |
}}) | |
); | |
expect(c.chart).toBeDefined(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment