Skip to content

Commit

Permalink
Add WIP tests
Browse files Browse the repository at this point in the history
  • Loading branch information
mjac0bs committed May 15, 2024
1 parent d9e2701 commit c1d423a
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 6 deletions.
Original file line number Diff line number Diff line change
@@ -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';
Expand All @@ -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(
<OveragePricing regionId="us-east" />
);
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(<OveragePricing regionId="br-gru" />);
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`,
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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(<EnableObjectStorageModal {...props} />)
Expand Down

0 comments on commit c1d423a

Please sign in to comment.