Skip to content
This repository was archived by the owner on Oct 11, 2022. It is now read-only.

Commit a978fa8

Browse files
authored
Merge branch 'master' into maintain-sub-styles
2 parents b7a8908 + 3bb3ec8 commit a978fa8

File tree

13 files changed

+98
-241
lines changed

13 files changed

+98
-241
lines changed

package.json

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -42,13 +42,10 @@
4242
"babel-preset-react": "^6.16.0",
4343
"babel-preset-react-hmre": "^1.1.1",
4444
"babel-preset-stage-0": "^6.16.0",
45-
"chai": "^3.5.0",
46-
"chai-enzyme": "^0.6.1",
4745
"cheerio": "^0.22.0",
4846
"coveralls": "^2.11.15",
4947
"css-loader": "^0.26.0",
5048
"css-modules-require-hook": "^4.0.5",
51-
"dirty-chai": "^1.2.2",
5249
"draft-js-plugins-editor": "2.0.0-rc2",
5350
"draft-js-prism":
5451
"ngs/draft-js-prism#6edb31c3805dd1de3fb897cc27fced6bac1bafbb",
@@ -83,13 +80,14 @@
8380
"react-github-fork-ribbon": "^0.4.4",
8481
"rimraf": "^2.5.4",
8582
"sinon": "^1.17.6",
86-
"sinon-chai": "^2.8.0",
8783
"static-site-generator-webpack-plugin": "^3.1.0",
8884
"style-loader": "^0.13.1",
8985
"url-loader": "^0.5.7",
9086
"webpack": "^1.13.3",
9187
"webpack-dev-middleware": "^1.8.4",
92-
"webpack-hot-middleware": "^2.13.2"
88+
"webpack-hot-middleware": "^2.13.2",
89+
"jest": "^21.1.0",
90+
"react-test-renderer": "^16.2.0"
9391
},
9492
"peerDependencies": {
9593
"draft-js-plugins-editor":
@@ -103,7 +101,6 @@
103101
"draft-js": "~0.10.1",
104102
"draft-js-checkable-list-item": "^2.0.5",
105103
"draft-js-prism-plugin": "^0.1.1",
106-
"immutable": "~3.7.4",
107-
"jest": "^21.1.0"
104+
"immutable": "~3.7.4"
108105
}
109106
}

src/components/Image/__test__/Image-test.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,9 @@
11
import React from "react";
22
import { ContentState } from "draft-js";
33
import { shallow } from "enzyme";
4-
import chai, { expect } from "chai";
5-
import chaiEnzyme from "chai-enzyme";
64

75
import Image from "../";
86

9-
chai.use(chaiEnzyme());
10-
117
describe("<Image />", () => {
128
it("renders anchor tag", () => {
139
const contentState = ContentState.createFromText(
@@ -24,7 +20,7 @@ describe("<Image />", () => {
2420
&nbsp;
2521
</Image>
2622
).html()
27-
).to.equal(
23+
).toEqual(
2824
'<span> <img src="http://cultofthepartyparrot.com/parrots/aussieparrot.gif" alt="alt" title="parrot"/></span>'
2925
);
3026
});
Lines changed: 12 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
11
import React from "react";
22
import { ContentState } from "draft-js";
3-
import { shallow } from "enzyme";
4-
import chai, { expect } from "chai";
5-
import chaiEnzyme from "chai-enzyme";
3+
import ShallowRenderer from "react-test-renderer/shallow";
64

7-
import Link from "../";
5+
const renderer = new ShallowRenderer();
86

9-
chai.use(chaiEnzyme());
7+
import Link from "../";
108

119
describe("<Link />", () => {
1210
it("renders anchor tag", () => {
@@ -17,14 +15,15 @@ describe("<Link />", () => {
1715
title: "parrot",
1816
});
1917
const entityKey = contentState.getLastCreatedEntityKey();
20-
expect(
21-
shallow(
22-
<Link entityKey={entityKey} contentState={contentState}>
23-
<b>Hello</b>
24-
</Link>
25-
).html()
26-
).to.equal(
27-
'<a href="http://cultofthepartyparrot.com/" title="parrot"><b>Hello</b></a>'
18+
renderer.render(
19+
<Link entityKey={entityKey} contentState={contentState}>
20+
<b>Hello</b>
21+
</Link>
22+
);
23+
expect(renderer.getRenderOutput()).toEqual(
24+
<a href="http://cultofthepartyparrot.com/" title="parrot">
25+
<b>Hello</b>
26+
</a>
2827
);
2928
});
3029
});

src/decorators/image/__test__/imageStrategy-test.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import chai, { expect } from "chai";
2-
import sinon from "sinon";
3-
import sinonChai from "sinon-chai";
41
import Draft from "draft-js";
52
import createImageStrategy from "../imageStrategy";
63

7-
chai.use(sinonChai);
8-
94
describe("imageStrategy", () => {
105
const contentState = Draft.convertFromRaw({
116
entityMap: {
@@ -40,9 +35,9 @@ describe("imageStrategy", () => {
4035
it("callbacks range", () => {
4136
const block = contentState.getBlockForKey("dtehj");
4237
const strategy = createImageStrategy();
43-
const cb = sinon.spy();
44-
expect(block).to.be.an("object");
38+
const cb = jest.fn();
39+
expect(typeof block).toBe("object");
4540
strategy(block, cb, contentState);
46-
expect(cb).to.have.been.calledWith(0, 1);
41+
expect(cb).toHaveBeenCalledWith(0, 1);
4742
});
4843
});

src/decorators/link/__test__/linkStrategy-test.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,6 @@
1-
import chai, { expect } from "chai";
2-
import sinon from "sinon";
3-
import sinonChai from "sinon-chai";
41
import Draft from "draft-js";
52
import createLinkStrategy from "../linkStrategy";
63

7-
chai.use(sinonChai);
8-
94
describe("linkStrategy", () => {
105
const contentState = Draft.convertFromRaw({
116
entityMap: {
@@ -39,9 +34,9 @@ describe("linkStrategy", () => {
3934
it("callbacks range", () => {
4035
const block = contentState.getBlockForKey("dtehj");
4136
const strategy = createLinkStrategy();
42-
const cb = sinon.spy();
43-
expect(block).to.be.an("object");
37+
const cb = jest.fn();
38+
expect(typeof block).toBe("object");
4439
strategy(block, cb, contentState);
45-
expect(cb).to.have.been.calledWith(7, 12);
40+
expect(cb).toHaveBeenCalledWith(7, 12);
4641
});
4742
});

src/modifiers/__test__/adjustBlockDepth-test.js

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
1-
import chai, { expect } from "chai";
21
import sinon from "sinon";
3-
import sinonChai from "sinon-chai";
42
import Draft, { EditorState, SelectionState } from "draft-js";
53
import adjustBlockDepth from "../adjustBlockDepth";
64

7-
chai.use(sinonChai);
8-
95
describe("adjustBlockDepth", () => {
106
const createEvent = () => {
117
const e = new window.KeyboardEvent("keydown", { shiftKey: false });
@@ -44,10 +40,10 @@ describe("adjustBlockDepth", () => {
4440
const event = createEvent();
4541
const editorState = createEditorState("unstyled", 0, 0);
4642
const newEditorState = adjustBlockDepth(editorState, event);
47-
expect(newEditorState).to.equal(editorState);
48-
expect(
49-
Draft.convertToRaw(newEditorState.getCurrentContent())
50-
).to.deep.equal(rawContentState("unstyled", 0, 0));
43+
expect(newEditorState).toEqual(editorState);
44+
expect(Draft.convertToRaw(newEditorState.getCurrentContent())).toEqual(
45+
rawContentState("unstyled", 0, 0)
46+
);
5147
});
5248
});
5349
[
@@ -60,10 +56,10 @@ describe("adjustBlockDepth", () => {
6056
const event = createEvent();
6157
const editorState = createEditorState(type, 0, 0);
6258
const newEditorState = adjustBlockDepth(editorState, event);
63-
expect(newEditorState).not.to.equal(editorState);
64-
expect(
65-
Draft.convertToRaw(newEditorState.getCurrentContent())
66-
).to.deep.equal(rawContentState(type, 0, 1));
59+
expect(newEditorState).not.toEqual(editorState);
60+
expect(Draft.convertToRaw(newEditorState.getCurrentContent())).toEqual(
61+
rawContentState(type, 0, 1)
62+
);
6763
});
6864
});
6965
});

src/modifiers/__test__/changeCurrentBlockType-test.js

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { expect } from "chai";
21
import Draft, { EditorState, SelectionState } from "draft-js";
32
import changeCurrentBlockType from "../changeCurrentBlockType";
43

@@ -40,10 +39,8 @@ describe("changeCurrentBlockType", () => {
4039
"Hello world",
4140
{ foo: "bar" }
4241
);
43-
expect(newEditorState).not.to.equal(editorState);
44-
expect(
45-
Draft.convertToRaw(newEditorState.getCurrentContent())
46-
).to.deep.equal(
42+
expect(newEditorState).not.toEqual(editorState);
43+
expect(Draft.convertToRaw(newEditorState.getCurrentContent())).toEqual(
4744
rawContentState("Hello world", "header-one", { foo: "bar" })
4845
);
4946
});
@@ -55,9 +52,9 @@ describe("changeCurrentBlockType", () => {
5552
"Hello world",
5653
null
5754
);
58-
expect(newEditorState).not.to.equal(editorState);
59-
expect(
60-
Draft.convertToRaw(newEditorState.getCurrentContent())
61-
).to.deep.equal(rawContentState("Hello world", "header-one", {}));
55+
expect(newEditorState).not.toEqual(editorState);
56+
expect(Draft.convertToRaw(newEditorState.getCurrentContent())).toEqual(
57+
rawContentState("Hello world", "header-one", {})
58+
);
6259
});
6360
});

src/modifiers/__test__/handleBlockType-test.js

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { expect } from "chai";
21
import Draft, { EditorState, SelectionState } from "draft-js";
32
import handleBlockType from "../handleBlockType";
43

@@ -33,10 +32,10 @@ describe("handleBlockType", () => {
3332
);
3433
it("does not convert block type", () => {
3534
const newEditorState = handleBlockType(editorState, " ");
36-
expect(newEditorState).to.equal(editorState);
37-
expect(
38-
Draft.convertToRaw(newEditorState.getCurrentContent())
39-
).to.deep.equal(rawContentState);
35+
expect(newEditorState).toEqual(editorState);
36+
expect(Draft.convertToRaw(newEditorState.getCurrentContent())).toEqual(
37+
rawContentState
38+
);
4039
});
4140
});
4241

@@ -513,10 +512,10 @@ describe("handleBlockType", () => {
513512
);
514513
it("converts block type", () => {
515514
const newEditorState = handleBlockType(editorState, character);
516-
expect(newEditorState).not.to.equal(editorState);
517-
expect(
518-
Draft.convertToRaw(newEditorState.getCurrentContent())
519-
).to.deep.equal(after);
515+
expect(newEditorState).not.toEqual(editorState);
516+
expect(Draft.convertToRaw(newEditorState.getCurrentContent())).toEqual(
517+
after
518+
);
520519
});
521520
});
522521
});

src/modifiers/__test__/handleInlineStyle-test.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -532,8 +532,6 @@ describe("handleInlineStyle", () => {
532532
it("converts block type", () => {
533533
const newEditorState = handleInlineStyle(editorState, character);
534534
expect(newEditorState).not.toEqual(editorState);
535-
// console.log('actual', JSON.stringify(Draft.convertToRaw(newEditorState.getCurrentContent()), null, 2))
536-
// console.log('expected', JSON.stringify(after, null, 2))
537535
expect(Draft.convertToRaw(newEditorState.getCurrentContent())).toEqual(
538536
after
539537
);

src/modifiers/__test__/insertImage-test.js

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { expect } from "chai";
21
import Draft, { EditorState, SelectionState } from "draft-js";
32
import insertImage from "../insertImage";
43

@@ -73,9 +72,9 @@ describe("insertImage", () => {
7372
matchArr.index = 4;
7473
matchArr.input = text;
7574
const newEditorState = insertImage(editorState, matchArr);
76-
expect(newEditorState).not.to.equal(editorState);
77-
expect(
78-
Draft.convertToRaw(newEditorState.getCurrentContent())
79-
).to.deep.equal(afterRawContentState);
75+
expect(newEditorState).not.toEqual(editorState);
76+
expect(Draft.convertToRaw(newEditorState.getCurrentContent())).toEqual(
77+
afterRawContentState
78+
);
8079
});
8180
});

0 commit comments

Comments
 (0)