Skip to content

Commit a9fad60

Browse files
committed
Add component tests
1 parent 6cf681f commit a9fad60

File tree

3 files changed

+48
-0
lines changed

3 files changed

+48
-0
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
"babel-preset-stage-0": "^6.16.0",
5656
"chai": "^3.5.0",
5757
"chai-enzyme": "^0.6.1",
58+
"cheerio": "^0.22.0",
5859
"css-loader": "^0.26.0",
5960
"css-modules-require-hook": "^4.0.5",
6061
"dirty-chai": "^1.2.2",
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import React from 'react';
2+
import { Entity } from 'draft-js';
3+
import { shallow } from 'enzyme';
4+
import chai, { expect } from 'chai';
5+
import chaiEnzyme from 'chai-enzyme';
6+
7+
import Image from '../';
8+
9+
chai.use(chaiEnzyme());
10+
11+
describe('<Image />', () => {
12+
it('renders anchor tag', () => {
13+
const entityKey = Entity.create('IMG', 'MUTABLE', {
14+
alt: 'alt',
15+
src: 'http://cultofthepartyparrot.com/parrots/aussieparrot.gif',
16+
title: 'parrot'
17+
});
18+
expect(
19+
shallow(<Image entityKey={entityKey}>&nbsp;</Image>).html()
20+
).to.equal(
21+
'<span> <img src="http://cultofthepartyparrot.com/parrots/aussieparrot.gif" alt="alt" title="parrot"/></span>'
22+
);
23+
});
24+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import { Entity } from 'draft-js';
3+
import { shallow } from 'enzyme';
4+
import chai, { expect } from 'chai';
5+
import chaiEnzyme from 'chai-enzyme';
6+
7+
import Link from '../';
8+
9+
chai.use(chaiEnzyme());
10+
11+
describe('<Link />', () => {
12+
it('renders anchor tag', () => {
13+
const entityKey = Entity.create('LINK', 'MUTABLE', {
14+
href: 'http://cultofthepartyparrot.com/',
15+
title: 'parrot'
16+
});
17+
expect(
18+
shallow(<Link entityKey={entityKey}><b>Hello</b></Link>).html()
19+
).to.equal(
20+
'<a href="http://cultofthepartyparrot.com/" title="parrot"><b>Hello</b></a>'
21+
);
22+
});
23+
});

0 commit comments

Comments
 (0)