Created
May 18, 2022 19:05
-
-
Save gparlakov/f321b444e66019dabb38a360336b6356 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
export function setup() { | |
// common | |
const router = <Router>( | |
(<unknown>jasmine.createSpyObj('router', ['navigate'])) | |
); | |
const canvas = new ElementRef(document.createElement('canvas')); | |
// the chart builder | |
const chartBuilder = jasmine.createSpy('chart builder'); | |
// the chart instance | |
const chart = jasmine.createSpyObj('The chart instance', [ | |
'getDataVisibility', | |
]); | |
let onClickCallback: Function = () => {}; | |
chartBuilder.and.callFake((i, o) => { | |
onClickCallback = o.options.onClick; | |
return chart; | |
}); | |
const builder = { | |
router, | |
canvas, | |
chartBuilder, | |
chart, | |
build: () => { | |
const c = new ChartComponent(router, chartBuilder); | |
c.canvas = canvas; | |
return c; | |
}, | |
callOnClickWith(index: number) { | |
onClickCallback(null, [{ index }]); | |
}, | |
withChartGetDataVisibilityReturning(b: boolean) { | |
chart.getDataVisibility.and.return(b); | |
return builder; | |
}, | |
}; | |
return builder; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment