-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Feat(web-react): Use the new Placement dictionary in
Dropdown
#DS-923
- Loading branch information
1 parent
07fe0df
commit ec31151
Showing
6 changed files
with
40 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
35 changes: 21 additions & 14 deletions
35
packages/web-react/src/components/Dropdown/__tests__/useDropdownStyleProps.test.ts
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 |
---|---|---|
@@ -1,35 +1,42 @@ | ||
import { renderHook } from '@testing-library/react-hooks'; | ||
import { DropdownPlacements } from '../../../types'; | ||
import { PlacementDictionaryType } from '../../../types/shared/dictionaries'; | ||
import { useDropdownStyleProps, UseDropdownStyleProps } from '../useDropdownStyleProps'; | ||
|
||
describe('useDropdownStyleProps', () => { | ||
it('should return defaults', () => { | ||
const props = { isOpen: true, placement: 'bottom-left' } as UseDropdownStyleProps; | ||
const { result } = renderHook(() => useDropdownStyleProps(props)); | ||
const { result } = renderHook(() => useDropdownStyleProps()); | ||
|
||
expect(result.current.classProps.contentClassName).toBe('Dropdown is-open Dropdown--bottom Dropdown--left'); | ||
expect(result.current.classProps.contentClassName).toBe('Dropdown Dropdown--bottomLeft'); | ||
expect(result.current.classProps.wrapperClassName).toBe('DropdownWrapper'); | ||
}); | ||
|
||
it('should render as open', () => { | ||
const props = { | ||
isOpen: true, | ||
} as UseDropdownStyleProps; | ||
const { result } = renderHook(() => useDropdownStyleProps(props)); | ||
|
||
expect(result.current.classProps.contentClassName).toBe('Dropdown Dropdown--bottomLeft is-open'); | ||
expect(result.current.classProps.triggerClassName).toBe('is-expanded'); | ||
}); | ||
|
||
it('should transfer additional props', () => { | ||
it('should change placement', () => { | ||
const props = { | ||
isOpen: false, | ||
placement: DropdownPlacements.BOTTOM_LEFT, | ||
transferProp: 'test', | ||
}; | ||
placement: 'top-right' as PlacementDictionaryType, | ||
} as UseDropdownStyleProps; | ||
const { result } = renderHook(() => useDropdownStyleProps(props)); | ||
|
||
expect(result.current.props).toEqual({ transferProp: 'test' }); | ||
expect(result.current.classProps.contentClassName).toBe('Dropdown Dropdown--topRight'); | ||
}); | ||
|
||
it('should change placement class', () => { | ||
it('should transfer additional props', () => { | ||
const props = { | ||
isOpen: false, | ||
placement: DropdownPlacements.TOP_RIGHT, | ||
}; | ||
transferProp: 'test', | ||
} as UseDropdownStyleProps; | ||
const { result } = renderHook(() => useDropdownStyleProps(props)); | ||
|
||
expect(result.current.classProps.contentClassName).toBe('Dropdown Dropdown--top Dropdown--right'); | ||
expect(result.current.classProps.contentClassName).toBe('Dropdown Dropdown--bottomLeft'); | ||
expect(result.current.props).toEqual({ transferProp: 'test' }); | ||
}); | ||
}); |
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