@@ -32,20 +32,35 @@ describe('PlotlyService', () => {
32
32
expect ( service . getPlotly ( ) ) . toBe ( Plotlyjs ) ;
33
33
} ) ) ;
34
34
35
- it ( 'should call plotly methods ' , inject ( [ PlotlyService ] , ( service :PlotlyService ) => {
35
+ it ( 'should call plotly.newPlot method ' , inject ( [ PlotlyService ] , ( service :PlotlyService ) => {
36
36
const plotly = service . getPlotly ( ) ;
37
- const methods :( keyof PlotlyService ) [ ] = [ 'plot' , 'update' , 'newPlot' ] ;
38
- methods . forEach ( methodName => {
39
- spyOn ( plotly , methodName ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
40
37
41
- ( service as any ) [ methodName ] ( 'one' as any , 'two' as any , 'three' as any , 'four' as any ) ;
42
- expect ( plotly [ methodName ] ) . toHaveBeenCalledWith ( 'one' , 'two' , 'three' , 'four' ) ;
43
- } ) ;
38
+ spyOn ( plotly , 'newPlot' ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
39
+ service . newPlot ( 'one' as any , 'two' as any , 'three' as any , 'four' as any ) ;
40
+ expect ( plotly . newPlot ) . toHaveBeenCalledWith ( 'one' , 'two' , 'three' , 'four' ) ;
41
+ } ) ) ;
44
42
45
- spyOn ( plotly . Plots , 'resize' ) ;
46
- service . resize ( 'one' as any ) ;
47
- expect ( plotly . Plots . resize ) . toHaveBeenCalledWith ( 'one' ) ;
43
+ it ( 'should call plotly.plot method' , inject ( [ PlotlyService ] , ( service :PlotlyService ) => {
44
+ const plotly = service . getPlotly ( ) ;
45
+
46
+ spyOn ( plotly , 'plot' ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
47
+ service . plot ( 'one' as any , 'two' as any , 'three' as any , 'four' as any ) ;
48
+ expect ( plotly . plot ) . toHaveBeenCalledWith ( 'one' , 'two' , 'three' , 'four' ) ;
49
+ } ) ) ;
50
+
51
+ it ( 'should call plotly.update method' , inject ( [ PlotlyService ] , ( service :PlotlyService ) => {
52
+ const plotly = service . getPlotly ( ) ;
53
+
54
+ spyOn ( plotly , 'react' ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
55
+ service . update ( 'one' as any , 'two' as any , 'three' as any , 'four' as any ) ;
56
+ expect ( plotly . react ) . toHaveBeenCalledWith ( 'one' , 'two' , 'three' , 'four' ) ;
48
57
} ) ) ;
49
58
59
+ it ( 'should call plotly.Plots.resize method' , inject ( [ PlotlyService ] , ( service :PlotlyService ) => {
60
+ const plotly = service . getPlotly ( ) ;
50
61
62
+ spyOn ( plotly . Plots , 'resize' ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
63
+ service . resize ( 'one' as any ) ;
64
+ expect ( plotly . Plots . resize ) . toHaveBeenCalledWith ( 'one' ) ;
65
+ } ) ) ;
51
66
} ) ;