From c1d423a244059075296f6b139c7f87f433c69aa6 Mon Sep 17 00:00:00 2001 From: mjac0bs Date: Tue, 14 May 2024 12:03:50 -0700 Subject: [PATCH] Add WIP tests --- .../BucketLanding/OveragePricing.test.tsx | 20 +++++++++++++------ .../EnableObjectStorageModal.test.tsx | 20 +++++++++++++++++++ 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/packages/manager/src/features/ObjectStorage/BucketLanding/OveragePricing.test.tsx b/packages/manager/src/features/ObjectStorage/BucketLanding/OveragePricing.test.tsx index efc2669ea5a..6b4c7f167eb 100644 --- a/packages/manager/src/features/ObjectStorage/BucketLanding/OveragePricing.test.tsx +++ b/packages/manager/src/features/ObjectStorage/BucketLanding/OveragePricing.test.tsx @@ -1,6 +1,7 @@ import { fireEvent } from '@testing-library/react'; import React from 'react'; +import { objectStorageTypeFactory } from 'src/factories'; import { OBJ_STORAGE_PRICE } from 'src/utilities/pricing/constants'; import { objectStoragePriceIncreaseMap } from 'src/utilities/pricing/dynamicPricing'; import { renderWithTheme } from 'src/utilities/testHelpers'; @@ -11,22 +12,29 @@ import { OveragePricing, } from './OveragePricing'; -describe('OveragePricing', () => { - it('Renders base overage pricing for a region without price increases', () => { +const mockObjectStorageTypes = objectStorageTypeFactory.build(); +const storageOveragePriceType = mockObjectStorageTypes[1]; + +describe('OveragePricing', async () => { + it.skip('Renders base overage pricing for a region without price increases', () => { const { getByText } = renderWithTheme( ); - getByText(`$${OBJ_STORAGE_PRICE.storage_overage} per GB`, { exact: false }); + getByText(`$${storageOveragePriceType.price.hourly} per GB`, { + exact: false, + }); getByText(`$${OBJ_STORAGE_PRICE.transfer_overage} per GB`, { exact: false, }); }); - it('Renders DC-specific overage pricing for a region with price increases', () => { + it.skip('Renders DC-specific overage pricing for a region with price increases', () => { const { getByText } = renderWithTheme(); getByText( - `$${objectStoragePriceIncreaseMap['br-gru'].storage_overage} per GB`, - { exact: false } + `$${storageOveragePriceType?.region_prices?.['br-gru']?.hourly} per GB`, + { + exact: false, + } ); getByText( `$${objectStoragePriceIncreaseMap['br-gru'].transfer_overage} per GB`, diff --git a/packages/manager/src/features/ObjectStorage/EnableObjectStorageModal.test.tsx b/packages/manager/src/features/ObjectStorage/EnableObjectStorageModal.test.tsx index e36ba887af3..3474219db6d 100644 --- a/packages/manager/src/features/ObjectStorage/EnableObjectStorageModal.test.tsx +++ b/packages/manager/src/features/ObjectStorage/EnableObjectStorageModal.test.tsx @@ -1,6 +1,7 @@ import { fireEvent, render } from '@testing-library/react'; import * as React from 'react'; +import { objectStorageTypeFactory } from 'src/factories'; import { OBJ_STORAGE_PRICE } from 'src/utilities/pricing/constants'; import { wrapWithTheme } from 'src/utilities/testHelpers'; @@ -23,7 +24,26 @@ const props: EnableObjectStorageProps = { open: true, }; +const queryMocks = vi.hoisted(() => ({ + useObjectStorageTypes: vi.fn().mockReturnValue({}), +})); + +vi.mock('src/queries/objectStorage', async () => { + const actual = await vi.importActual('src/queries/objectStorage'); + return { + ...actual, + useObjectStorageTypesQuery: queryMocks.useObjectStorageTypes, + }; +}); + describe('EnableObjectStorageModal', () => { + beforeEach(() => { + const mockObjectStorageTypes = objectStorageTypeFactory.build(); + queryMocks.useObjectStorageTypes.mockReturnValue({ + data: mockObjectStorageTypes, + }); + }); + it('includes a header', () => { const { getAllByText } = render( wrapWithTheme()