-
Notifications
You must be signed in to change notification settings - Fork 333
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #281 from zeit-ui/rc
chore: release v1.7.0
- Loading branch information
Showing
50 changed files
with
2,142 additions
and
39 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 |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import React, { useEffect } from 'react' | ||
import { mount } from 'enzyme' | ||
import { AutoComplete, useInput } from 'components' | ||
|
||
describe('UseInput', () => { | ||
it('should follow change with use-input', () => { | ||
let log = '' | ||
const logSpy = jest.spyOn(console, 'log').mockImplementation(msg => (log = msg)) | ||
const MockInput: React.FC<{ value?: string }> = ({ value }) => { | ||
const { state, setState, bindings } = useInput('') | ||
useEffect(() => { | ||
if (value) setState(value) | ||
}, [value]) | ||
useEffect(() => { | ||
if (state) console.log(state) | ||
}, [state]) | ||
return <AutoComplete {...bindings} /> | ||
} | ||
|
||
const wrapper = mount(<MockInput />) | ||
wrapper.setProps({ value: 'test' }) | ||
const input = wrapper.find('input').at(0).getDOMNode() as HTMLInputElement | ||
|
||
expect(input.value).toEqual('test') | ||
expect(log).toContain('test') | ||
|
||
log = '' | ||
wrapper | ||
.find('input') | ||
.at(0) | ||
.simulate('change', { target: { value: 'test-change' } }) | ||
expect(log).toContain('test-change') | ||
logSpy.mockRestore() | ||
}) | ||
|
||
it('should follow change with use-input', () => { | ||
const MockInput: React.FC<{ value?: string; resetValue?: boolean }> = ({ | ||
value, | ||
resetValue, | ||
}) => { | ||
const { reset, setState, bindings } = useInput('') | ||
useEffect(() => { | ||
if (value) setState(value) | ||
}, [value]) | ||
useEffect(() => { | ||
if (resetValue) reset() | ||
}, [resetValue]) | ||
return <AutoComplete {...bindings} /> | ||
} | ||
|
||
const wrapper = mount(<MockInput />) | ||
wrapper.setProps({ value: 'test' }) | ||
let input = wrapper.find('input').at(0).getDOMNode() as HTMLInputElement | ||
expect(input.value).toEqual('test') | ||
|
||
wrapper.setProps({ resetValue: true }) | ||
input = wrapper.find('input').at(0).getDOMNode() as HTMLInputElement | ||
expect(input.value).toEqual('') | ||
}) | ||
}) |
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
85 changes: 85 additions & 0 deletions
85
components/breadcrumbs/__tests__/__snapshots__/breadcrumbs.test.tsx.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,85 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`Breadcrumbs should redefined all separators 1`] = ` | ||
"<nav class=\\"\\"><span class=\\"breadcrums-item \\">test-1</span><div class=\\"separator \\">*<style> | ||
.separator { | ||
display: inline-flex; | ||
margin: 0 8px; | ||
user-select: none; | ||
pointer-events: none; | ||
align-items: center; | ||
} | ||
</style></div><span class=\\"breadcrums-item \\">test-2</span><style> | ||
nav { | ||
margin: 0; | ||
padding: 0; | ||
line-height: inherit; | ||
color: #888; | ||
font-size: 1rem; | ||
box-sizing: border-box; | ||
display: flex; | ||
align-items: center; | ||
} | ||
nav :global(.link:hover) { | ||
color: rgba(0, 112, 243, 0.85); | ||
} | ||
nav > :global(span:last-of-type) { | ||
color: #444; | ||
} | ||
nav > :global(.separator:last-child) { | ||
display: none; | ||
} | ||
nav :global(svg) { | ||
width: 1em; | ||
height: 1em; | ||
margin: 0 4px; | ||
} | ||
nav :global(.breadcrums-item) { | ||
display: inline-flex; | ||
align-items: center; | ||
} | ||
</style></nav>" | ||
`; | ||
|
||
exports[`Breadcrumbs should render correctly 1`] = ` | ||
"<nav class=\\"\\"><span class=\\"breadcrums-item \\">test-1</span><style> | ||
nav { | ||
margin: 0; | ||
padding: 0; | ||
line-height: inherit; | ||
color: #888; | ||
font-size: 1rem; | ||
box-sizing: border-box; | ||
display: flex; | ||
align-items: center; | ||
} | ||
nav :global(.link:hover) { | ||
color: rgba(0, 112, 243, 0.85); | ||
} | ||
nav > :global(span:last-of-type) { | ||
color: #444; | ||
} | ||
nav > :global(.separator:last-child) { | ||
display: none; | ||
} | ||
nav :global(svg) { | ||
width: 1em; | ||
height: 1em; | ||
margin: 0 4px; | ||
} | ||
nav :global(.breadcrums-item) { | ||
display: inline-flex; | ||
align-items: center; | ||
} | ||
</style></nav>" | ||
`; |
Oops, something went wrong.