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

Commit ddc0488

Browse files
committed
Add unit test
1 parent 935fe75 commit ddc0488

File tree

1 file changed

+34
-1
lines changed

1 file changed

+34
-1
lines changed

src/__test__/plugin.test.js

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,7 @@ describe("draft-js-markdown-plugin", () => {
180180
expect(subject()).toBe("not-handled");
181181
});
182182

183-
it("resets curent inline style", () => {
183+
it("resets current inline style", () => {
184184
currentRawContentState = {
185185
entityMap: {},
186186
blocks: [
@@ -545,6 +545,39 @@ describe("draft-js-markdown-plugin", () => {
545545
" "
546546
);
547547
});
548+
it("unstickys inline style", () => {
549+
currentRawContentState = {
550+
entityMap: {},
551+
blocks: [
552+
{
553+
key: "item1",
554+
text: "item1",
555+
type: "unstyled",
556+
depth: 0,
557+
inlineStyleRanges: [
558+
{ offset: 0, length: 5, style: "BOLD" },
559+
],
560+
entityRanges: [],
561+
data: {},
562+
},
563+
],
564+
};
565+
566+
currentSelectionState = currentSelectionState.merge({
567+
focusOffset: 5,
568+
anchorOffset: 5,
569+
});
570+
571+
expect(subject()).toBe("handled");
572+
expect(store.setEditorState).toHaveBeenCalled();
573+
newEditorState = store.setEditorState.mock.calls[0][0];
574+
const block = newEditorState.getCurrentContent().getLastBlock();
575+
const length = block.getLength();
576+
expect(block.getInlineStyleAt(length - 1).toJS()).toEqual([]);
577+
expect(block.getInlineStyleAt(length - 2).toJS()).toEqual([
578+
"BOLD",
579+
]);
580+
});
548581
});
549582
});
550583
describe("character is not a space", () => {

0 commit comments

Comments
 (0)