Skip to content

Commit 4674e3c

Browse files
committedMar 15, 2018
Made all tests pass
1 parent 5901c28 commit 4674e3c

File tree

3 files changed

+74
-55
lines changed

3 files changed

+74
-55
lines changed
 

‎.babelrc

+18-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,20 @@
11
{
2-
"presets": ["env", "react"]
2+
"presets": [
3+
[
4+
"es2015",
5+
{
6+
"modules": false
7+
}
8+
],
9+
"react",
10+
"stage-0"
11+
],
12+
"env": {
13+
"start": {
14+
"presets": ["react-hmre"]
15+
},
16+
"test": {
17+
"presets": ["es2015", "react", "stage-0"]
18+
}
19+
}
320
}

‎package.json

+3-2
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@
44
"description": "React component for syntax highlighting",
55
"main": "index.js",
66
"scripts": {
7-
"prepublish":
8-
"babel ./src --out-dir ./lib --plugins=transform-class-properties,transform-react-jsx --presets=env",
7+
"prepublish": "babel ./src --out-dir ./lib --plugins=transform-class-properties,transform-react-jsx --presets=env",
98
"test": "jest"
109
},
1110
"repository": {
@@ -39,7 +38,9 @@
3938
"babel-plugin-transform-class-properties": "^6.24.1",
4039
"babel-plugin-transform-react-jsx": "^6.24.1",
4140
"babel-preset-env": "^1.6.1",
41+
"babel-preset-es2015": "^6.24.1",
4242
"babel-preset-react": "^6.24.1",
43+
"babel-preset-stage-0": "^6.24.1",
4344
"eslint": "^3.19.0",
4445
"eslint-plugin-react": "^6.10.3",
4546
"html-loader": "^0.4.5",

‎test/highlight.test.js

+53-52
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,55 @@
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'
56

67
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

Comments
 (0)
Please sign in to comment.