From 84829f5439778cdaa2c0499891e8b710c52b3a35 Mon Sep 17 00:00:00 2001 From: Tyler Johnson Date: Thu, 28 Jul 2016 12:43:44 -0600 Subject: [PATCH] add tests for calling wrapInline twice (#197) --- .../fixtures/wrap-inline/twice/index.js | 23 +++++++++++++++++++ .../fixtures/wrap-inline/twice/input.yaml | 7 ++++++ .../fixtures/wrap-inline/twice/output.yaml | 16 +++++++++++++ 3 files changed, 46 insertions(+) create mode 100644 test/transforms/fixtures/wrap-inline/twice/index.js create mode 100644 test/transforms/fixtures/wrap-inline/twice/input.yaml create mode 100644 test/transforms/fixtures/wrap-inline/twice/output.yaml diff --git a/test/transforms/fixtures/wrap-inline/twice/index.js b/test/transforms/fixtures/wrap-inline/twice/index.js new file mode 100644 index 000000000..c66ea2e1c --- /dev/null +++ b/test/transforms/fixtures/wrap-inline/twice/index.js @@ -0,0 +1,23 @@ + +import assert from 'assert' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const text = texts.first() + const range = selection.merge({ + anchorKey: text.key, + anchorOffset: 7, + focusKey: text.key, + focusOffset: 11 + }) + + const next = state + .transform() + .moveTo(range) + .wrapInline('inner') + .wrapInline('outer') + .apply() + + return next +} diff --git a/test/transforms/fixtures/wrap-inline/twice/input.yaml b/test/transforms/fixtures/wrap-inline/twice/input.yaml new file mode 100644 index 000000000..34c5c02d8 --- /dev/null +++ b/test/transforms/fixtures/wrap-inline/twice/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: before word after diff --git a/test/transforms/fixtures/wrap-inline/twice/output.yaml b/test/transforms/fixtures/wrap-inline/twice/output.yaml new file mode 100644 index 000000000..27fedbbd5 --- /dev/null +++ b/test/transforms/fixtures/wrap-inline/twice/output.yaml @@ -0,0 +1,16 @@ +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + text: "before " + - kind: inline + type: outer + nodes: + - kind: inline + type: inner + nodes: + - kind: text + text: word + - kind: text + text: " after"