@@ -24,16 +24,19 @@ describe('PlotlyService', () => {
2424
2525 it ( 'should check the plotly dependency' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
2626 ( PlotlyService as any ) . plotly = undefined ;
27- expect ( ( ) => service . getPlotly ( ) ) . toThrowError ( `Peer dependency plotly.js isn't installed` ) ;
28- PlotlyService . setPlotly ( PlotlyJS ) ;
27+
28+ return service . getPlotly ( ) . catch ( err => {
29+ expect ( err . message ) . toBe ( `Peer dependency plotly.js isn't installed` ) ;
30+ PlotlyService . setPlotly ( PlotlyJS ) ;
31+ } ) ;
2932 } ) ) ;
3033
3134 it ( 'should be created' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
3235 expect ( service ) . toBeTruthy ( ) ;
3336 } ) ) ;
3437
35- it ( 'should return the plotly object' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
36- expect ( service . getPlotly ( ) ) . toBe ( PlotlyJS ) ;
38+ it ( 'should return the plotly object' , inject ( [ PlotlyService ] , async ( service : PlotlyService ) => {
39+ expect ( await service . getPlotly ( ) ) . toBe ( PlotlyJS ) ;
3740 } ) ) ;
3841
3942 it ( 'should set the module name' , ( ) => {
@@ -47,7 +50,7 @@ describe('PlotlyService', () => {
4750
4851 it ( 'should call plotly.newPlot method' , inject ( [ PlotlyService ] , async ( service : PlotlyService ) => {
4952 return new Promise < void > ( async ( resolve ) => {
50- const plotly = service . getPlotly ( ) ;
53+ const plotly = await ( service as any ) . getPlotly ( ) ;
5154 PlotlyService . setPlotly ( 'waiting' ) ;
5255
5356 setTimeout ( ( ) => PlotlyService . setPlotly ( PlotlyJS ) , 100 ) ;
@@ -62,8 +65,8 @@ describe('PlotlyService', () => {
6265 } ) ;
6366 } ) ) ;
6467
65- it ( 'should call plotly.plot method' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
66- const plotly = service . getPlotly ( ) ;
68+ it ( 'should call plotly.plot method' , inject ( [ PlotlyService ] , async ( service : PlotlyService ) => {
69+ const plotly = await service . getPlotly ( ) ;
6770
6871 spyOn ( plotly , 'plot' ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
6972 service . plot ( 'one' as any , 'two' as any , 'three' as any , 'four' as any ) ;
@@ -73,8 +76,8 @@ describe('PlotlyService', () => {
7376 expect ( plotly . plot ) . toHaveBeenCalledWith ( 'one' , { data : 'two' , layout : 'three' , config : 'four' , frames : 'five' } ) ;
7477 } ) ) ;
7578
76- it ( 'should call plotly.update method' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
77- const plotly = service . getPlotly ( ) ;
79+ it ( 'should call plotly.update method' , inject ( [ PlotlyService ] , async ( service : PlotlyService ) => {
80+ const plotly = await service . getPlotly ( ) ;
7881
7982 spyOn ( plotly , 'react' ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
8083 service . update ( 'one' as any , 'two' as any , 'three' as any , 'four' as any ) ;
@@ -84,8 +87,8 @@ describe('PlotlyService', () => {
8487 expect ( plotly . react ) . toHaveBeenCalledWith ( 'one' , { data : 'two' , layout : 'three' , config : 'four' , frames : 'five' } ) ;
8588 } ) ) ;
8689
87- it ( 'should call plotly.Plots.resize method' , inject ( [ PlotlyService ] , ( service : PlotlyService ) => {
88- const plotly = service . getPlotly ( ) ;
90+ it ( 'should call plotly.Plots.resize method' , inject ( [ PlotlyService ] , async ( service : PlotlyService ) => {
91+ const plotly = await service . getPlotly ( ) ;
8992
9093 spyOn ( plotly . Plots , 'resize' ) . and . returnValue ( new Promise ( ( ) => { } ) ) ;
9194 service . resize ( 'one' as any ) ;
0 commit comments