File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ import { PlotlyModule } from './plotly.module' ;
2+ import { PlotlyService } from './plotly.service' ;
3+
4+ describe ( 'PlotlyModule' , ( ) => {
5+ afterEach ( ( ) => {
6+ PlotlyService . plotly = undefined ;
7+ } ) ;
8+
9+ // it('should throw error when PlotlyJS object is invalid', () => {
10+ // expect(() => new PlotlyModule()).toThrowError(
11+ // 'Invalid PlotlyJS object. Please check https://github.com/plotly/angular-plotly.js#quick-start to see how to add PlotlyJS to your project.'
12+ // );
13+ // });
14+
15+ it ( 'should not throw error when plotlyjs has plot function' , ( ) => {
16+ PlotlyService . plotly = { plot ( ) : void { } } ;
17+ expect ( ( ) => new PlotlyModule ( ) ) . not . toThrow ( ) ;
18+ } ) ;
19+
20+ it ( 'should not throw error when plotlyjs has newPlot function' , ( ) => {
21+ PlotlyService . plotly = { newPlot ( ) : void { } } ;
22+ expect ( ( ) => new PlotlyModule ( ) ) . not . toThrow ( ) ;
23+ } ) ;
24+
25+ describe ( 'forRoot' , ( ) => {
26+ it ( 'should call PlotlyService.setPlotly with provided plotlyjs and return module config' , ( ) => {
27+ const fakePlotly = { react ( ) : void { } } ;
28+ spyOn ( PlotlyService , 'setPlotly' ) ;
29+ const result = PlotlyModule . forRoot ( fakePlotly ) ;
30+ expect ( PlotlyService . setPlotly ) . toHaveBeenCalledWith ( fakePlotly ) ;
31+ expect ( result . ngModule ) . toBe ( PlotlyModule ) ;
32+ expect ( result . providers ) . toEqual ( [ PlotlyService ] ) ;
33+ } ) ;
34+ } ) ;
35+ } ) ;
You can’t perform that action at this time.
0 commit comments