-
-
Notifications
You must be signed in to change notification settings - Fork 9.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add ability to parse line breaks into <br/> for Docgen description in…
… info addon
- Loading branch information
1 parent
5c3fc6c
commit adfd81a
Showing
4 changed files
with
65 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
// import { shallow } from 'enzyme'; | ||
import renderer from 'react-test-renderer'; | ||
|
||
import { multiLineText } from './PropTable'; | ||
|
||
describe('PropTable', () => { | ||
describe('multiLineText', () => { | ||
const singleLine = 'Foo bar baz'; | ||
const unixMultiLineText = 'foo \n bar \n baz'; | ||
const windowsMultiLineText = 'foo \r bar \r baz'; | ||
|
||
it('should return its input for a single line of text', () => { | ||
expect(multiLineText(singleLine)).toBe(singleLine); | ||
}); | ||
it('should return an array for unix multiline text', () => { | ||
expect(multiLineText(unixMultiLineText)).toHaveLength(3); | ||
}); | ||
it('should return an array for windows multiline text', () => { | ||
expect(multiLineText(windowsMultiLineText)).toHaveLength(3); | ||
}); | ||
it('should have 2 br tags for 3 lines of text', () => { | ||
const tree = renderer.create(multiLineText(unixMultiLineText)).toJSON(); | ||
expect(tree).toMatchSnapshot(); | ||
}); | ||
}); | ||
}); |
20 changes: 20 additions & 0 deletions
20
addons/info/src/components/__snapshots__/PropTable.test.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,20 @@ | ||
// Jest Snapshot v1, https://goo.gl/fbAQLP | ||
|
||
exports[`PropTable multiLineText should have 2 br tags for 3 lines of text 1`] = ` | ||
Array [ | ||
<span> | ||
foo | ||
</span>, | ||
<span> | ||
<br /> | ||
bar | ||
</span>, | ||
<span> | ||
<br /> | ||
baz | ||
</span>, | ||
] | ||
`; |
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