From 035ae4451aaaca2ca014b21208516fcdeb22ac68 Mon Sep 17 00:00:00 2001 From: Ian Storm Taylor Date: Thu, 21 Jul 2016 11:59:39 -0700 Subject: [PATCH] add more mark tests --- .../add-mark/with-mark-object/index.js | 22 +++++++++++++++++++ .../add-mark/with-mark-object/input.yaml | 8 +++++++ .../add-mark/with-mark-object/output.yaml | 13 +++++++++++ .../add-mark/with-plain-object/index.js | 20 +++++++++++++++++ .../add-mark/with-plain-object/input.yaml | 8 +++++++ .../add-mark/with-plain-object/output.yaml | 13 +++++++++++ 6 files changed, 84 insertions(+) create mode 100644 test/transforms/fixtures/add-mark/with-mark-object/index.js create mode 100644 test/transforms/fixtures/add-mark/with-mark-object/input.yaml create mode 100644 test/transforms/fixtures/add-mark/with-mark-object/output.yaml create mode 100644 test/transforms/fixtures/add-mark/with-plain-object/index.js create mode 100644 test/transforms/fixtures/add-mark/with-plain-object/input.yaml create mode 100644 test/transforms/fixtures/add-mark/with-plain-object/output.yaml diff --git a/test/transforms/fixtures/add-mark/with-mark-object/index.js b/test/transforms/fixtures/add-mark/with-mark-object/index.js new file mode 100644 index 000000000..6b8ba9f19 --- /dev/null +++ b/test/transforms/fixtures/add-mark/with-mark-object/index.js @@ -0,0 +1,22 @@ + +import { Mark } from '../../../../..' + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + + return state + .transform() + .moveTo({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 1 + }) + .addMark(Mark.create({ + type: 'bold', + data: { key: 'value' } + })) + .apply() +} diff --git a/test/transforms/fixtures/add-mark/with-mark-object/input.yaml b/test/transforms/fixtures/add-mark/with-mark-object/input.yaml new file mode 100644 index 000000000..b1be31e90 --- /dev/null +++ b/test/transforms/fixtures/add-mark/with-mark-object/input.yaml @@ -0,0 +1,8 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/add-mark/with-mark-object/output.yaml b/test/transforms/fixtures/add-mark/with-mark-object/output.yaml new file mode 100644 index 000000000..c400de58a --- /dev/null +++ b/test/transforms/fixtures/add-mark/with-mark-object/output.yaml @@ -0,0 +1,13 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: w + marks: + - type: bold + data: + key: value + - text: ord diff --git a/test/transforms/fixtures/add-mark/with-plain-object/index.js b/test/transforms/fixtures/add-mark/with-plain-object/index.js new file mode 100644 index 000000000..587103e6d --- /dev/null +++ b/test/transforms/fixtures/add-mark/with-plain-object/index.js @@ -0,0 +1,20 @@ + +export default function (state) { + const { document, selection } = state + const texts = document.getTexts() + const first = texts.first() + + return state + .transform() + .moveTo({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 1 + }) + .addMark({ + type: 'bold', + data: { key: 'value' } + }) + .apply() +} diff --git a/test/transforms/fixtures/add-mark/with-plain-object/input.yaml b/test/transforms/fixtures/add-mark/with-plain-object/input.yaml new file mode 100644 index 000000000..b1be31e90 --- /dev/null +++ b/test/transforms/fixtures/add-mark/with-plain-object/input.yaml @@ -0,0 +1,8 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: word diff --git a/test/transforms/fixtures/add-mark/with-plain-object/output.yaml b/test/transforms/fixtures/add-mark/with-plain-object/output.yaml new file mode 100644 index 000000000..c400de58a --- /dev/null +++ b/test/transforms/fixtures/add-mark/with-plain-object/output.yaml @@ -0,0 +1,13 @@ + +nodes: + - kind: block + type: paragraph + nodes: + - kind: text + ranges: + - text: w + marks: + - type: bold + data: + key: value + - text: ord