-
Notifications
You must be signed in to change notification settings - Fork 19
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin' into knguyen2/ent-9159
- Loading branch information
Showing
12 changed files
with
173 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
35 changes: 35 additions & 0 deletions
35
src/Configuration/Customers/CustomerDetailView/tests/CustomerCard.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/* eslint-disable react/prop-types */ | ||
import { screen, render } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
import { formatDate } from '../../data/utils'; | ||
import CustomerCard from '../CustomerCard'; | ||
|
||
jest.mock('../../data/utils', () => ({ | ||
getEnterpriseCustomer: jest.fn(), | ||
formatDate: jest.fn(), | ||
})); | ||
|
||
const mockData = { | ||
uuid: 'test-id', | ||
name: 'Test Customer Name', | ||
slug: 'customer-6', | ||
created: '2024-07-23T20:02:57.651943Z', | ||
modified: '2024-07-23T20:02:57.651943Z', | ||
}; | ||
|
||
describe('CustomerCard', () => { | ||
it('renders customer card data', () => { | ||
formatDate.mockReturnValue('July 23, 2024'); | ||
render( | ||
<IntlProvider locale="en"> | ||
<CustomerCard enterpriseCustomer={mockData} /> | ||
</IntlProvider>, | ||
); | ||
expect(screen.getByText('test-id')).toBeInTheDocument(); | ||
expect(screen.getByText('/customer-6/')).toBeInTheDocument(); | ||
expect(screen.getByText('Created July 23, 2024 • Last modified July 23, 2024')).toBeInTheDocument(); | ||
expect(screen.getByText('Test Customer Name')); | ||
}); | ||
}); |
44 changes: 44 additions & 0 deletions
44
src/Configuration/Customers/CustomerDetailView/tests/CustomerViewContainer.test.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
/* eslint-disable react/prop-types */ | ||
import { screen, render, waitFor } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
|
||
import { IntlProvider } from '@edx/frontend-platform/i18n'; | ||
import { getEnterpriseCustomer, formatDate } from '../../data/utils'; | ||
import CustomerViewContainer from '../CustomerViewContainer'; | ||
|
||
jest.mock('react-router-dom', () => ({ | ||
...jest.requireActual('react-router-dom'), | ||
useParams: () => ({ id: 'test-id' }), | ||
})); | ||
|
||
jest.mock('../../data/utils', () => ({ | ||
getEnterpriseCustomer: jest.fn(), | ||
formatDate: jest.fn(), | ||
})); | ||
|
||
describe('CustomerViewContainer', () => { | ||
it('renders data', async () => { | ||
getEnterpriseCustomer.mockReturnValue([{ | ||
uuid: 'test-id', | ||
name: 'Test Customer Name', | ||
slug: 'customer-6', | ||
created: '2024-07-23T20:02:57.651943Z', | ||
modified: '2024-07-23T20:02:57.651943Z', | ||
}]); | ||
formatDate.mockReturnValue('July 23, 2024'); | ||
render( | ||
<IntlProvider locale="en"> | ||
<CustomerViewContainer /> | ||
</IntlProvider>, | ||
); | ||
await waitFor(() => { | ||
expect(screen.getByText('test-id')).toBeInTheDocument(); | ||
expect(screen.getByText('/customer-6/')).toBeInTheDocument(); | ||
expect(screen.getByText('Created July 23, 2024 • Last modified July 23, 2024')).toBeInTheDocument(); | ||
const customerNameText = screen.getAllByText('Test Customer Name'); | ||
customerNameText.forEach(customerName => { | ||
expect(customerName).toBeInTheDocument(); | ||
}); | ||
}); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters