Skip to content

Commit 385673b

Browse files
committed
Fixing tests
1 parent 2fb1397 commit 385673b

File tree

1 file changed

+25
-10
lines changed

1 file changed

+25
-10
lines changed

src/app/plotly/plotly.service.spec.ts

Lines changed: 25 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,35 @@ describe('PlotlyService', () => {
3232
expect(service.getPlotly()).toBe(Plotlyjs);
3333
}));
3434

35-
it('should call plotly methods', inject([PlotlyService], (service: PlotlyService) => {
35+
it('should call plotly.newPlot method', inject([PlotlyService], (service: PlotlyService) => {
3636
const plotly = service.getPlotly();
37-
const methods: (keyof PlotlyService)[] = ['plot', 'update', 'newPlot'];
38-
methods.forEach(methodName => {
39-
spyOn(plotly, methodName).and.returnValue(new Promise(() => {}));
4037

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+
}));
4442

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');
4857
}));
4958

59+
it('should call plotly.Plots.resize method', inject([PlotlyService], (service: PlotlyService) => {
60+
const plotly = service.getPlotly();
5061

62+
spyOn(plotly.Plots, 'resize').and.returnValue(new Promise(() => {}));
63+
service.resize('one' as any);
64+
expect(plotly.Plots.resize).toHaveBeenCalledWith('one');
65+
}));
5166
});

0 commit comments

Comments
 (0)