|
1 | 1 | import { waitFor } from '@testing-library/react';
|
2 | 2 |
|
3 |
| -import * as awsForecast from './awsForecast'; |
4 |
| -import * as awsOcpForecast from './awsOcpForecast'; |
5 |
| -import * as azureForecast from './azureForecast'; |
6 |
| -import * as azureOcpForecast from './azureOcpForecast'; |
7 |
| -import { ForecastType } from './forecast'; |
8 |
| -import * as gcpForecast from './gcpForecast'; |
9 |
| -import * as gcpOcpForecast from './gcpOcpForecast'; |
10 |
| -import * as ibmForecast from './ibmForecast'; |
11 |
| -import * as ociForecast from './ociForecast'; |
12 |
| -import * as ocpCloudForecast from './ocpCloudForecast'; |
13 |
| -import * as ocpForecast from './ocpForecast'; |
14 |
| -import * as rhelForecast from './rhelForecast'; |
| 3 | +import { ForecastPathsType, ForecastType } from './forecast'; |
| 4 | +import * as forecastUtils from './forecastUtils'; |
15 | 5 |
|
16 |
| -jest.spyOn(awsForecast, 'runForecast'); |
17 |
| -jest.spyOn(awsOcpForecast, 'runForecast'); |
18 |
| -jest.spyOn(azureForecast, 'runForecast'); |
19 |
| -jest.spyOn(azureOcpForecast, 'runForecast'); |
20 |
| -jest.spyOn(gcpForecast, 'runForecast'); |
21 |
| -jest.spyOn(gcpOcpForecast, 'runForecast'); |
22 |
| -jest.spyOn(ibmForecast, 'runForecast'); |
23 |
| -jest.spyOn(ociForecast, 'runForecast'); |
24 |
| -jest.spyOn(ocpCloudForecast, 'runForecast'); |
25 |
| -jest.spyOn(ocpForecast, 'runForecast'); |
26 |
| -jest.spyOn(rhelForecast, 'runForecast'); |
| 6 | +jest.spyOn(forecastUtils, 'runForecast'); |
27 | 7 |
|
28 | 8 | test('runForecast API request for AWS', async () => {
|
29 |
| - awsForecast.runForecast(ForecastType.cost, ''); |
30 |
| - await waitFor(() => expect(awsForecast.runForecast).toHaveBeenCalled()); |
| 9 | + forecastUtils.runForecast(ForecastPathsType.aws, ForecastType.cost, ''); |
| 10 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
31 | 11 | });
|
32 | 12 |
|
33 | 13 | test('runForecast API request for OCP on AWS', async () => {
|
34 |
| - awsOcpForecast.runForecast(ForecastType.cost, ''); |
35 |
| - await waitFor(() => expect(awsOcpForecast.runForecast).toHaveBeenCalled()); |
| 14 | + forecastUtils.runForecast(ForecastPathsType.awsOcp, ForecastType.cost, ''); |
| 15 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
36 | 16 | });
|
37 | 17 |
|
38 | 18 | test('runForecast API request for Azure', async () => {
|
39 |
| - azureForecast.runForecast(ForecastType.cost, ''); |
40 |
| - await waitFor(() => expect(azureForecast.runForecast).toHaveBeenCalled()); |
| 19 | + forecastUtils.runForecast(ForecastPathsType.azure, ForecastType.cost, ''); |
| 20 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
41 | 21 | });
|
42 | 22 |
|
43 | 23 | test('runForecast API request for OCP on Azure', async () => {
|
44 |
| - azureOcpForecast.runForecast(ForecastType.cost, ''); |
45 |
| - await waitFor(() => expect(azureOcpForecast.runForecast).toHaveBeenCalled()); |
| 24 | + forecastUtils.runForecast(ForecastPathsType.azureOcp, ForecastType.cost, ''); |
| 25 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
46 | 26 | });
|
47 | 27 |
|
48 | 28 | test('runForecast API request for GCP', async () => {
|
49 |
| - gcpForecast.runForecast(ForecastType.cost, ''); |
50 |
| - await waitFor(() => expect(gcpForecast.runForecast).toHaveBeenCalled()); |
| 29 | + forecastUtils.runForecast(ForecastPathsType.gcp, ForecastType.cost, ''); |
| 30 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
51 | 31 | });
|
52 | 32 |
|
53 | 33 | test('runForecast API request for OCP on GCP', async () => {
|
54 |
| - gcpOcpForecast.runForecast(ForecastType.cost, ''); |
55 |
| - await waitFor(() => expect(gcpOcpForecast.runForecast).toHaveBeenCalled()); |
| 34 | + forecastUtils.runForecast(ForecastPathsType.gcpOcp, ForecastType.cost, ''); |
| 35 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
56 | 36 | });
|
57 | 37 |
|
58 | 38 | test('runForecast API request for IBM', async () => {
|
59 |
| - ibmForecast.runForecast(ForecastType.cost, ''); |
60 |
| - await waitFor(() => expect(ibmForecast.runForecast).toHaveBeenCalled()); |
| 39 | + forecastUtils.runForecast(ForecastPathsType.ibm, ForecastType.cost, ''); |
| 40 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
61 | 41 | });
|
62 | 42 |
|
63 | 43 | test('runForecast API request for OCI', async () => {
|
64 |
| - ociForecast.runForecast(ForecastType.cost, ''); |
65 |
| - await waitFor(() => expect(ociForecast.runForecast).toHaveBeenCalled()); |
| 44 | + forecastUtils.runForecast(ForecastPathsType.oci, ForecastType.cost, ''); |
| 45 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
66 | 46 | });
|
67 | 47 |
|
68 | 48 | test('runForecast API request for all cloud filtered by OCP', async () => {
|
69 |
| - ocpCloudForecast.runForecast(ForecastType.cost, ''); |
70 |
| - await waitFor(() => expect(ocpCloudForecast.runForecast).toHaveBeenCalled()); |
| 49 | + forecastUtils.runForecast(ForecastPathsType.ocpCloud, ForecastType.cost, ''); |
| 50 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
71 | 51 | });
|
72 | 52 |
|
73 | 53 | test('runForecast API request for OCP', async () => {
|
74 |
| - ocpForecast.runForecast(ForecastType.cost, ''); |
75 |
| - await waitFor(() => expect(ocpForecast.runForecast).toHaveBeenCalled()); |
| 54 | + forecastUtils.runForecast(ForecastPathsType.ocp, ForecastType.cost, ''); |
| 55 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
76 | 56 | });
|
77 | 57 |
|
78 | 58 | test('runForecast API request for RHEL', async () => {
|
79 |
| - rhelForecast.runForecast(ForecastType.cost, ''); |
80 |
| - await waitFor(() => expect(rhelForecast.runForecast).toHaveBeenCalled()); |
| 59 | + forecastUtils.runForecast(ForecastPathsType.rhel, ForecastType.cost, ''); |
| 60 | + await waitFor(() => expect(forecastUtils.runForecast).toHaveBeenCalled()); |
81 | 61 | });
|
0 commit comments