|
1 | | -import Highlight from '../src'; |
2 | | -import ReactDOM from 'react-dom'; |
3 | | -import TestUtils from 'react-dom/test-utils'; |
4 | | -import ReactDOMServer from 'react-dom/server'; |
| 1 | +import Highlight from '../src' |
| 2 | +import ReactDOM from 'react-dom' |
| 3 | +import TestUtils from 'react-dom/test-utils' |
| 4 | +import ReactDOMServer from 'react-dom/server' |
| 5 | +import React from 'react' |
5 | 6 |
|
6 | 7 | describe('highlight', () => { |
7 | | - it('should display test inside it', () => { |
8 | | - const text = TestUtils.renderIntoDocument( |
9 | | - <Highlight>Some text</Highlight> |
10 | | - ); |
11 | | - |
12 | | - expect(ReactDOM.findDOMNode(text).textContent).toBe('Some text'); |
13 | | - }); |
14 | | - |
15 | | - it('should have pre and code tags in markup', () => { |
16 | | - const text = ReactDOMServer.renderToStaticMarkup( |
17 | | - <Highlight>Some text</Highlight> |
18 | | - ); |
19 | | - |
20 | | - expect(text).toBe('<pre><code>Some text</code></pre>'); |
21 | | - }); |
22 | | - |
23 | | - it('should assign className prop', () => { |
24 | | - const text = ReactDOMServer.renderToStaticMarkup( |
25 | | - <Highlight className='html'>Some text</Highlight> |
26 | | - ); |
27 | | - |
28 | | - expect(text).toBe('<pre><code class="html">Some text</code></pre>'); |
29 | | - }); |
30 | | - |
31 | | - it('should render children in span', () => { |
32 | | - const text = ReactDOMServer.renderToStaticMarkup( |
33 | | - <Highlight element='span'>Some text</Highlight> |
34 | | - ); |
35 | | - |
36 | | - expect(text).toBe('<span>Some text</span>'); |
37 | | - }); |
38 | | - |
39 | | - it('should render innerHTML in span', () => { |
40 | | - const text = ReactDOMServer.renderToStaticMarkup( |
41 | | - <Highlight innerHTML={true} element='span'>Some text</Highlight> |
42 | | - ); |
43 | | - |
44 | | - expect(text).toBe('<span>Some text</span>'); |
45 | | - }); |
46 | | - |
47 | | - it('should accept innerHTML prop', () => { |
48 | | - const text = TestUtils.renderIntoDocument( |
49 | | - <Highlight innerHTML={true}>{"<div>Sometext</div>"}</Highlight> |
50 | | - ); |
51 | | - |
52 | | - expect(ReactDOM.findDOMNode(text).textContent).toBe('Sometext'); |
53 | | - }); |
54 | | -}); |
| 8 | + test('should display text inside it', () => { |
| 9 | + const text = TestUtils.renderIntoDocument(<Highlight>Some text</Highlight>) |
| 10 | + |
| 11 | + expect(ReactDOM.findDOMNode(text).textContent).toBe('Some text') |
| 12 | + }) |
| 13 | + |
| 14 | + test('should have pre and code tags in markup', () => { |
| 15 | + const text = ReactDOMServer.renderToStaticMarkup( |
| 16 | + <Highlight>Some text</Highlight> |
| 17 | + ) |
| 18 | + |
| 19 | + expect(text).toBe('<pre><code>Some text</code></pre>') |
| 20 | + }) |
| 21 | + |
| 22 | + test('should assign className prop', () => { |
| 23 | + const text = ReactDOMServer.renderToStaticMarkup( |
| 24 | + <Highlight className="html">Some text</Highlight> |
| 25 | + ) |
| 26 | + |
| 27 | + expect(text).toBe('<pre><code class="html">Some text</code></pre>') |
| 28 | + }) |
| 29 | + |
| 30 | + test('should render children in span', () => { |
| 31 | + const text = ReactDOMServer.renderToStaticMarkup( |
| 32 | + <Highlight element="span">Some text</Highlight> |
| 33 | + ) |
| 34 | + |
| 35 | + expect(text).toBe('<span>Some text</span>') |
| 36 | + }) |
| 37 | + |
| 38 | + test('should render innerHTML in span', () => { |
| 39 | + const text = ReactDOMServer.renderToStaticMarkup( |
| 40 | + <Highlight innerHTML={true} element="span"> |
| 41 | + Some text |
| 42 | + </Highlight> |
| 43 | + ) |
| 44 | + |
| 45 | + expect(text).toBe('<span>Some text</span>') |
| 46 | + }) |
| 47 | + |
| 48 | + test('should accept innerHTML prop', () => { |
| 49 | + const text = TestUtils.renderIntoDocument( |
| 50 | + <Highlight innerHTML={true}>{'<div>Sometext</div>'}</Highlight> |
| 51 | + ) |
| 52 | + |
| 53 | + expect(ReactDOM.findDOMNode(text).textContent).toBe('Sometext') |
| 54 | + }) |
| 55 | +}) |
0 commit comments