-
Notifications
You must be signed in to change notification settings - Fork 6
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
dbe440c
commit 95f91f4
Showing
1 changed file
with
124 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
import { MemoryRouter } from 'react-router-dom'; | ||
import { screen } from'@testing-library/react'; | ||
Check warning on line 2 in lib/DocumentFilter/DocumentFilterArray.test.js GitHub Actions / ui / Install and lint / Install and lint
|
||
import { waitFor } from '@folio/jest-config-stripes/testing-library/react'; | ||
import { renderWithIntl, Button, TestForm, Dropdown} from '@folio/stripes-erm-testing'; | ||
|
||
import { translationsProperties } from '../../test/jest/helpers'; | ||
|
||
import DocumentFilterArray from './DocumentFilterArray'; | ||
const handleSubmit = jest.fn(); | ||
const translatedContentOptions = [ | ||
{ | ||
"value": "alternateNames", | ||
Check failure on line 12 in lib/DocumentFilter/DocumentFilterArray.test.js GitHub Actions / ui / Install and lint / Install and lint
|
||
"label": "Alternative names" | ||
Check failure on line 13 in lib/DocumentFilter/DocumentFilterArray.test.js GitHub Actions / ui / Install and lint / Install and lint
|
||
}, | ||
{ | ||
"value": "agreementContentTypes", | ||
Check failure on line 16 in lib/DocumentFilter/DocumentFilterArray.test.js GitHub Actions / ui / Install and lint / Install and lint
|
||
"label": "Content types" | ||
}, | ||
{ | ||
"value": "contacts", | ||
"label": "Internal contacts" | ||
}, | ||
{ | ||
"value": "orgs", | ||
"label": "Organizations" | ||
}, | ||
{ | ||
"value": "items", | ||
"label": "Agreement lines" | ||
}, | ||
{ | ||
"value": "linkedLicenses", | ||
"label": "Linked licenses" | ||
}, | ||
{ | ||
"value": "externalLicenseDocs", | ||
"label": "External licenses" | ||
}, | ||
{ | ||
"value": "supplementaryDocs", | ||
"label": "Supplementary documents" | ||
}, | ||
{ | ||
"value": "usageDataProviders", | ||
"label": "Usage data" | ||
}, | ||
{ | ||
"value": "relatedAgreements", | ||
"label": "Related agreements" | ||
}, | ||
{ | ||
"value": "tags", | ||
"label": "Tags" | ||
} | ||
]; | ||
const onSubmit = jest.fn(); | ||
jest.mock('./DocumentFilterField', () => () => <div>DocumentFilterField</div>); | ||
|
||
let renderComponent; | ||
describe('DocumentFilterArray', () => { | ||
beforeEach(() => { | ||
renderComponent = renderWithIntl( | ||
<MemoryRouter> | ||
<TestForm onSubmit={onSubmit}> | ||
<DocumentFilterArray | ||
translatedContentOptions={translatedContentOptions} | ||
name={"agreementContent"} | ||
handleSubmit={handleSubmit} | ||
/> | ||
</TestForm>, | ||
</MemoryRouter>, | ||
translationsProperties | ||
); | ||
}); | ||
|
||
test('renders the And/Or dropdown button', async () => { | ||
await Dropdown('Add filter').exists(); | ||
}); | ||
|
||
describe('clicking \'Add filter\' button', () => { | ||
beforeEach(async () => { | ||
await waitFor(async () => { | ||
await Button('Add filter').click(); | ||
}); | ||
}); | ||
|
||
it('should render the \'AND\' and \'OR\' dropdown buttons', async () => { | ||
await Button('AND').exists(); | ||
await Button('OR').exists(); | ||
}); | ||
}); | ||
|
||
describe('clicking \'OR\' button', () => { | ||
beforeEach(async () => { | ||
await waitFor(async () => { | ||
await Button('Add filter').click(); | ||
await Button('OR').click(); | ||
}); | ||
}); | ||
|
||
it('should display the OR label', async () => { | ||
const { getAllByText } = renderComponent; | ||
await waitFor(async () => { | ||
expect(getAllByText('OR').length).toEqual(2); | ||
}); | ||
}); | ||
}); | ||
|
||
describe('clicking \'AND\' button', () => { | ||
beforeEach(async () => { | ||
await waitFor(async () => { | ||
await Button('Add filter').click(); | ||
await Button('AND').click(); | ||
}); | ||
}); | ||
|
||
it('should display the AND label', async () => { | ||
const { getAllByText } = renderComponent; | ||
await waitFor(async () => { | ||
expect(getAllByText('AND').length).toEqual(2); | ||
}); | ||
}); | ||
}); | ||
}); |