-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Update tests to use Draft.js 0.10 API
- Loading branch information
1 parent
5e40560
commit d12c859
Showing
4 changed files
with
29 additions
and
11 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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { Entity } from 'draft-js'; | ||
import { convertFromHTML, ContentState } from 'draft-js'; | ||
import Link from './Link'; | ||
|
||
describe('Link', () => { | ||
|
@@ -9,18 +9,30 @@ describe('Link', () => { | |
}); | ||
|
||
it('renders', () => { | ||
const entityKey = Entity.create('LINK', 'MUTABLE', { url: 'http://example.com/' }); | ||
const contentBlocks = convertFromHTML('<h1>aaaaaaaaaa</h1>'); | ||
const contentState = ContentState.createFromBlockArray(contentBlocks); | ||
const contentStateWithEntity = contentState.createEntity('LINK', 'MUTABLE', { url: 'http://example.com/' }); | ||
const entityKey = contentStateWithEntity.getLastCreatedEntityKey(); | ||
expect(shallow(( | ||
<Link entityKey={entityKey}> | ||
<Link | ||
entityKey={entityKey} | ||
contentState={contentStateWithEntity} | ||
> | ||
<span>Test children</span> | ||
</Link> | ||
))).toMatchSnapshot(); | ||
}); | ||
|
||
it('renders email', () => { | ||
const entityKey = Entity.create('LINK', 'MUTABLE', { url: 'mailto:[email protected]' }); | ||
const contentBlocks = convertFromHTML('<h1>aaaaaaaaaa</h1>'); | ||
const contentState = ContentState.createFromBlockArray(contentBlocks); | ||
const contentStateWithEntity = contentState.createEntity('LINK', 'MUTABLE', { url: 'mailto:[email protected]' }); | ||
const entityKey = contentStateWithEntity.getLastCreatedEntityKey(); | ||
expect(shallow(( | ||
<Link entityKey={entityKey}> | ||
<Link | ||
entityKey={entityKey} | ||
contentState={contentStateWithEntity} | ||
> | ||
<span>Test children</span> | ||
</Link> | ||
))).toMatchSnapshot(); | ||
|
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