This repository has been archived by the owner on Oct 25, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
9e4bcc5
commit 625af88
Showing
2 changed files
with
108 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
/** @jsx jsx */ | ||
|
||
import { jsx } from '../__test-utils__/jsx'; | ||
|
||
import React from 'react'; | ||
import renderer from 'react-test-renderer'; | ||
import configureStore from 'redux-mock-store'; | ||
import { Provider } from 'react-intl-redux'; | ||
import { wait } from '@testing-library/react'; | ||
import ReactDOM from 'react-dom'; | ||
|
||
import { Editor } from 'slate'; | ||
import { withReact } from 'slate-react'; | ||
// import TextBlockEdit from './TextBlockEdit'; | ||
import { withHandleBreak } from './decorators'; | ||
|
||
// const mockStore = configureStore(); | ||
|
||
// ReactDOM.createPortal = (node) => node; | ||
|
||
// window.getSelection = () => null; | ||
|
||
describe('TextBlockEdit', () => { | ||
// it('renders w/o errors', async () => { | ||
// const store = mockStore({ | ||
// intl: { | ||
// locale: 'en', | ||
// messages: {}, | ||
// }, | ||
// }); | ||
|
||
// let root; | ||
|
||
// renderer.act(() => { | ||
// root = renderer.create( | ||
// <Provider store={store}> | ||
// <TextBlockEdit | ||
// data={{ value: [{ type: 'paragraph', children: [{ text: '' }] }] }} | ||
// selected={true} | ||
// /> | ||
// </Provider>, | ||
// ); | ||
// }); | ||
// await wait(() => { | ||
// expect(root.toJSON()).toMatchSnapshot(); | ||
// }); | ||
// }); | ||
|
||
it('withHandleBreak decorator', async () => { | ||
// const editor = withHandleBreak( | ||
// 5, | ||
// () => {}, | ||
// () => {}, | ||
// () => {}, | ||
// )(withReact(input)); | ||
|
||
const input = ( | ||
<editor> | ||
<block> | ||
test | ||
<cursor /> | ||
</block> | ||
</editor> | ||
); | ||
|
||
const text = 'http://localhost:3000'; | ||
|
||
const output = ( | ||
<editor> | ||
<block>testhttp://localhost:3000</block> | ||
</editor> | ||
); | ||
|
||
console.log('etc', [output]); | ||
|
||
const editor = withReact(input); | ||
editor.insertText(text); | ||
|
||
// TODO: debug, get into the source, to understand where is __source added and why | ||
output.children[0]['__source'] = editor.children[0]['__source']; | ||
|
||
expect(output.children).toEqual(editor.children); | ||
}); | ||
}); |
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,24 @@ | ||
// import assert from 'assert'; | ||
// import { Editor } from 'slate'; | ||
import { createHyperscript } from 'slate-hyperscript'; | ||
|
||
// const withTest = (editor) => { | ||
// const { isInline, isVoid } = editor; | ||
|
||
// editor.isInline = (element) => { | ||
// return element.inline === true ? true : isInline(element); | ||
// }; | ||
|
||
// editor.isVoid = (element) => { | ||
// return element.void === true ? true : isVoid(element); | ||
// }; | ||
|
||
// return editor; | ||
// }; | ||
|
||
export const jsx = createHyperscript({ | ||
elements: { | ||
block: {}, | ||
inline: { inline: true }, | ||
}, | ||
}); |