-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4cccf41
commit 84421e3
Showing
4 changed files
with
151 additions
and
3 deletions.
There are no files selected for viewing
46 changes: 46 additions & 0 deletions
46
...tionDetails/OrganizationBankingInfo/BankingInformationCard/BankingInformationCard.test.js
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,46 @@ | ||
import { render, screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
|
||
import { BankingInformationCard } from './BankingInformationCard'; | ||
|
||
const bankingInformation = { | ||
isPrimary: true, | ||
bankName: 'Bank name', | ||
bankAccountNumber: 'Acc No', | ||
transitNumber: 't-123', | ||
categoryId: 'category-id', | ||
accountTypeId: 'acc-type-id', | ||
notes: 'Notes', | ||
}; | ||
|
||
const defaultProps = { | ||
bankingAccountTypesMap: { | ||
[bankingInformation.accountTypeId]: { name: 'Acc type' }, | ||
}, | ||
bankingInformation, | ||
categoriesMap: { | ||
[bankingInformation.categoryId]: { value: 'Category' }, | ||
}, | ||
}; | ||
|
||
const renderBankingInformationCard = (props = {}) => render( | ||
<BankingInformationCard | ||
{...defaultProps} | ||
{...props} | ||
/>, | ||
); | ||
|
||
describe('BankingInformationCard', () => { | ||
it('should render banking information item values', () => { | ||
renderBankingInformationCard(); | ||
|
||
expect(screen.getByText('ui-organizations.primaryItem')).toBeInTheDocument(); | ||
expect(screen.getByText(defaultProps.categoriesMap[bankingInformation.categoryId].value)).toBeInTheDocument(); | ||
expect( | ||
screen.getByText(defaultProps.bankingAccountTypesMap[bankingInformation.accountTypeId].name), | ||
).toBeInTheDocument(); | ||
expect(screen.getByText(bankingInformation.bankAccountNumber)).toBeInTheDocument(); | ||
expect(screen.getByText(bankingInformation.bankName)).toBeInTheDocument(); | ||
expect(screen.getByText(bankingInformation.notes)).toBeInTheDocument(); | ||
expect(screen.getByText(bankingInformation.transitNumber)).toBeInTheDocument(); | ||
}); | ||
}); |
86 changes: 86 additions & 0 deletions
86
...Organizations/OrganizationDetails/OrganizationBankingInfo/OrganizationBankingInfo.test.js
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,86 @@ | ||
import { render, screen } from '@folio/jest-config-stripes/testing-library/react'; | ||
|
||
import { organization } from 'fixtures'; | ||
import { | ||
useBankingAccountTypes, | ||
useCategories, | ||
useOrganizationBankingInformation, | ||
} from '../../../common/hooks'; | ||
import { OrganizationBankingInfo } from './OrganizationBankingInfo'; | ||
|
||
jest.mock('../../../common/hooks', () => ({ | ||
...jest.requireActual('../../../common/hooks'), | ||
useBankingAccountTypes: jest.fn(), | ||
useCategories: jest.fn(), | ||
useOrganizationBankingInformation: jest.fn(), | ||
})); | ||
|
||
const defaultProps = { | ||
organization, | ||
}; | ||
|
||
const bankingAccountTypes = [ | ||
{ id: 'bank-acc-type-id-1', name: 'Acc type 1' }, | ||
{ id: 'bank-acc-type-id-2', name: 'Acc type 2' }, | ||
]; | ||
|
||
const categories = [ | ||
{ id: 'category-id-1', value: 'Category 1' }, | ||
{ id: 'category-id-2', value: 'Category 2' }, | ||
]; | ||
|
||
const bankingInformation = [ | ||
{ | ||
id: 'bank-info-id-1', | ||
isPrimary: true, | ||
bankName: 'Bank name 1', | ||
bankAccountNumber: 'Bank acc No 1', | ||
transitNumber: 't-1', | ||
accountTypeId: bankingAccountTypes[0].id, | ||
categoryId: categories[0].id, | ||
notes: 'Notes', | ||
}, | ||
{ | ||
id: 'bank-info-id-2', | ||
bankName: 'Bank name 2', | ||
accountTypeId: bankingAccountTypes[1].id, | ||
categoryId: categories[1].id, | ||
}, | ||
{ | ||
id: 'bank-info-id-3', | ||
bankName: 'Bank name 3', | ||
accountTypeId: 'deleted-acc-type-id', | ||
categoryId: 'deleted-category-id', | ||
}, | ||
{ | ||
id: 'bank-info-id-4', | ||
bankName: 'Bank name 4', | ||
}, | ||
]; | ||
|
||
const renderOrganizationBankingInfo = (props = {}) => render( | ||
<OrganizationBankingInfo | ||
{...defaultProps} | ||
{...props} | ||
/>, | ||
); | ||
|
||
describe('OrganizationBankingInfo', () => { | ||
beforeEach(() => { | ||
useBankingAccountTypes | ||
.mockClear() | ||
.mockReturnValue({ bankingAccountTypes, isFetching: false }); | ||
useCategories | ||
.mockClear() | ||
.mockReturnValue({ categories, isFetching: false }); | ||
useOrganizationBankingInformation | ||
.mockClear() | ||
.mockReturnValue({ bankingInformation, isFetching: false }); | ||
}); | ||
|
||
it('should render card for each of banking information items', () => { | ||
renderOrganizationBankingInfo(); | ||
|
||
expect(screen.getAllByText(/^Bank name.*/)).toHaveLength(bankingInformation.length); | ||
}); | ||
}); |
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