-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/DHIS2-15796
- Loading branch information
Showing
8 changed files
with
178 additions
and
16 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
59 changes: 59 additions & 0 deletions
59
src/components/OrgUnitDimension/__tests__/OrgUnitDimension.spec.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,59 @@ | ||
import { shallow } from 'enzyme' | ||
import React from 'react' | ||
import OrgUnitDimension from '../OrgUnitDimension.js' | ||
|
||
describe('The OrgUnitDimension component', () => { | ||
let props | ||
let shallowOrgUnitDimension | ||
|
||
const getWrapper = () => { | ||
if (!shallowOrgUnitDimension) { | ||
shallowOrgUnitDimension = shallow(<OrgUnitDimension {...props} />) | ||
} | ||
return shallowOrgUnitDimension | ||
} | ||
|
||
beforeEach(() => { | ||
props = { | ||
roots: [], | ||
selected: [], | ||
onSelect: jest.fn(), | ||
hideGroupSelect: false, | ||
hideLevelSelect: false, | ||
hideUserOrgUnits: false, | ||
warning: '', | ||
} | ||
shallowOrgUnitDimension = undefined | ||
}) | ||
|
||
it('matches the snapshot', () => { | ||
const wrapper = getWrapper() | ||
expect(wrapper).toMatchSnapshot() | ||
}) | ||
|
||
it('calls onSelect when an organisation unit is selected', () => { | ||
const wrapper = getWrapper() | ||
const orgUnitTree = wrapper.find('OrganisationUnitTree') | ||
const testOrgUnit = { | ||
id: 'testId', | ||
path: '/testPath', | ||
displayName: 'Test Org Unit', | ||
checked: true, | ||
} | ||
orgUnitTree.props().onChange(testOrgUnit) | ||
expect(props.onSelect).toHaveBeenCalledWith({ | ||
dimensionId: 'ou', | ||
items: [{ id: 'testId', path: '/testPath', name: 'Test Org Unit' }], | ||
}) | ||
}) | ||
|
||
it('calls onSelect with an empty array when selection is cleared', () => { | ||
const wrapper = getWrapper() | ||
const deselectButton = wrapper.find('Button[onClick]') | ||
deselectButton.simulate('click') | ||
expect(props.onSelect).toHaveBeenCalledWith({ | ||
dimensionId: 'ou', | ||
items: [], | ||
}) | ||
}) | ||
}) |
94 changes: 94 additions & 0 deletions
94
src/components/OrgUnitDimension/__tests__/__snapshots__/OrgUnitDimension.spec.js.snap
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,94 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`The OrgUnitDimension component matches the snapshot 1`] = ` | ||
<div | ||
className="container" | ||
> | ||
<div | ||
className="userOrgUnitsWrapper" | ||
> | ||
<Checkbox | ||
checked={false} | ||
dataTest="dhis2-uicore-checkbox" | ||
dense={true} | ||
indeterminate={false} | ||
label="User organisation unit" | ||
onChange={[Function]} | ||
/> | ||
<Checkbox | ||
checked={false} | ||
dataTest="dhis2-uicore-checkbox" | ||
dense={true} | ||
indeterminate={false} | ||
label="User sub-units" | ||
onChange={[Function]} | ||
/> | ||
<Checkbox | ||
checked={false} | ||
dataTest="dhis2-uicore-checkbox" | ||
dense={true} | ||
indeterminate={false} | ||
label="User sub-x2-units" | ||
onChange={[Function]} | ||
/> | ||
</div> | ||
<div | ||
className="orgUnitTreeWrapper" | ||
> | ||
<OrganisationUnitTree | ||
dataTest="org-unit-tree" | ||
filter={Array []} | ||
highlighted={Array []} | ||
initiallyExpanded={Array []} | ||
onChange={[Function]} | ||
renderNodeLabel={[Function]} | ||
roots={Array []} | ||
selected={Array []} | ||
/> | ||
</div> | ||
<div | ||
className="selectsWrapper" | ||
> | ||
<MultiSelect | ||
dataTest="org-unit-level-select" | ||
dense={true} | ||
loading={true} | ||
onChange={[Function]} | ||
placeholder="Select a level" | ||
selected={Array []} | ||
/> | ||
<MultiSelect | ||
dataTest="org-unit-group-select" | ||
dense={true} | ||
loading={true} | ||
onChange={[Function]} | ||
placeholder="Select a group" | ||
selected={Array []} | ||
/> | ||
</div> | ||
<div | ||
className="summaryWrapper" | ||
> | ||
<span | ||
className="summaryText" | ||
> | ||
Nothing selected | ||
</span> | ||
<div | ||
className="deselectButton" | ||
> | ||
<Button | ||
dataTest="dhis2-uicore-button" | ||
disabled={true} | ||
onClick={[Function]} | ||
secondary={true} | ||
small={true} | ||
type="button" | ||
> | ||
Deselect all | ||
</Button> | ||
</div> | ||
</div> | ||
<style /> | ||
</div> | ||
`; |
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