This repository was archived by the owner on Nov 1, 2019. It is now read-only.
-
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.
refactor: Select, Dropdown, Tooltip (#207)
* refactor: Refactored Dropdown, Tooltip and Select components * fix: Fixed undefined interface usage in Code. Updated highlighter package * fix: smoke tests
- Loading branch information
1 parent
8f490a5
commit 87c5fa5
Showing
19 changed files
with
4,834 additions
and
3,777 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,71 +1,55 @@ | ||
import React, { Ref } from 'react' | ||
import React from 'react' | ||
import { mount } from 'enzyme' | ||
import 'jest-styled-components' | ||
|
||
import { Dropdown } from '.' | ||
|
||
test('hides content, when open is false', () => { | ||
const dropdown = mount(( | ||
<Dropdown | ||
open={false} | ||
test='dropdown' | ||
renderTrigger={({ ref }: { ref: Ref<HTMLButtonElement> }) => <button ref={ref}>toggle</button>} | ||
> | ||
<div>test</div> | ||
</Dropdown> | ||
)) | ||
|
||
const dropdownContent = dropdown.find({ 'data-test': 'dropdown-content' }) | ||
expect(dropdownContent).toHaveLength(0) | ||
dropdown.unmount() | ||
}) | ||
|
||
test('displays content, when open is true', () => { | ||
const dropdown = mount(( | ||
<Dropdown | ||
open={true} | ||
test='dropdown' | ||
renderTrigger={({ ref }: { ref: Ref<HTMLButtonElement> }) => <button ref={ref}>toggle</button>} | ||
> | ||
<div>test</div> | ||
</Dropdown> | ||
)) | ||
|
||
const dropdownContent = dropdown.find({ 'data-test': 'dropdown-content' }) | ||
expect(dropdownContent.hostNodes()).toHaveLength(1) | ||
dropdown.unmount() | ||
}) | ||
|
||
test('uses min. width, when useTriggerWidth is false', () => { | ||
const dropdown = mount(( | ||
<Dropdown | ||
open={true} | ||
useTriggerWidth={false} | ||
test='dropdown' | ||
renderTrigger={({ ref }: { ref: Ref<HTMLButtonElement> }) => <button ref={ref}>toggle</button>} | ||
> | ||
<div>test</div> | ||
</Dropdown> | ||
)) | ||
|
||
const dropdownContent = dropdown.find({ 'data-test': 'dropdown-content' }) | ||
expect(dropdownContent).toHaveStyleRule('min-width', '160px') | ||
dropdown.unmount() | ||
}) | ||
|
||
test('uses full available width, when useTriggerWidth is true', () => { | ||
const dropdown = mount(( | ||
<Dropdown | ||
open={true} | ||
useTriggerWidth={true} | ||
test='dropdown' | ||
renderTrigger={({ ref }: { ref: Ref<HTMLButtonElement> }) => <button ref={ref}>toggle</button>} | ||
> | ||
<div>test</div> | ||
</Dropdown> | ||
)) | ||
|
||
const dropdownContent = dropdown.find({ 'data-test': 'dropdown-content' }) | ||
expect(dropdownContent).toHaveStyleRule('min-width', '100%') | ||
dropdown.unmount() | ||
describe('The Dropdown component', () => { | ||
test('hides content, when open is false', () => { | ||
const wrapper = mount(( | ||
<Dropdown open={false} trigger={<button>toggle</button>}> | ||
<div>test</div> | ||
</Dropdown> | ||
)) | ||
|
||
const dropdownContent = wrapper.find(Dropdown.Content) | ||
expect(dropdownContent).toHaveLength(0) | ||
wrapper.unmount() | ||
}) | ||
|
||
test('displays content, when open is true', () => { | ||
const wrapper = mount(( | ||
<Dropdown open={true} trigger={<button>toggle</button>}> | ||
<div>test</div> | ||
</Dropdown> | ||
)) | ||
|
||
const dropdownContent = wrapper.find(Dropdown.Content) | ||
expect(dropdownContent).toHaveLength(1) | ||
wrapper.unmount() | ||
}) | ||
|
||
test('uses min. width, when useTriggerWidth is false', () => { | ||
const wrapper = mount(( | ||
<Dropdown open={true} useTriggerWidth={false} trigger={<button>toggle</button>}> | ||
<div>test</div> | ||
</Dropdown> | ||
)) | ||
|
||
const dropdownContent = wrapper.find(Dropdown.Content) | ||
expect(dropdownContent).toHaveStyleRule('min-width', '160px') | ||
wrapper.unmount() | ||
}) | ||
|
||
test('uses full available width, when useTriggerWidth is true', () => { | ||
const wrapper = mount(( | ||
<Dropdown open={true} useTriggerWidth={true} trigger={<button>toggle</button>}> | ||
<div>test</div> | ||
</Dropdown> | ||
)) | ||
|
||
const dropdownContent = wrapper.find(Dropdown.Content) | ||
expect(dropdownContent).toHaveStyleRule('min-width', '100%') | ||
wrapper.unmount() | ||
}) | ||
}) |
Oops, something went wrong.