diff --git a/test/transforms/fixtures/add-mark/across-inlines/index.js b/test/transforms/fixtures/add-mark/across-inlines/index.js index f292021bf..8b2025eb8 100644 --- a/test/transforms/fixtures/add-mark/across-inlines/index.js +++ b/test/transforms/fixtures/add-mark/across-inlines/index.js @@ -1,18 +1,25 @@ +import assert from 'assert' + export default function (state) { const { document, selection } = state const texts = document.getTexts() const first = texts.first() const second = texts.last() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 2, + focusKey: second.key, + focusOffset: 2 + }) - return state + const next = state .transform() - .moveTo({ - anchorKey: first.key, - anchorOffset: 2, - focusKey: second.key, - focusOffset: 2 - }) + .moveTo(range) .addMark('bold') .apply() + + assert.deepEqual(next.selection.toJS(), range.toJS()) + + return next } diff --git a/test/transforms/fixtures/add-mark/collapsed-selection-off-again/index.js b/test/transforms/fixtures/add-mark/collapsed-selection-off-again/index.js index e27e1f18d..6c7064e5c 100644 --- a/test/transforms/fixtures/add-mark/collapsed-selection-off-again/index.js +++ b/test/transforms/fixtures/add-mark/collapsed-selection-off-again/index.js @@ -1,20 +1,28 @@ +import assert from 'assert' + export default function (state) { const { document, selection } = state const texts = document.getTexts() const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 0 + }) - return state + const next = state .transform() .moveTo({ - anchorKey: first.key, - anchorOffset: 0, - focusKey: first.key, - focusOffset: 0 }) .addMark('bold') .insertText('a') .removeMark('bold') .insertText('b') .apply() + + assert.deepEqual(next.selection.toJS(), range.moveForward().moveForward().toJS()) + + return next } diff --git a/test/transforms/fixtures/add-mark/collapsed-selection/index.js b/test/transforms/fixtures/add-mark/collapsed-selection/index.js index d833f91f4..88b143ef3 100644 --- a/test/transforms/fixtures/add-mark/collapsed-selection/index.js +++ b/test/transforms/fixtures/add-mark/collapsed-selection/index.js @@ -1,18 +1,25 @@ +import assert from 'assert' + export default function (state) { const { document, selection } = state const texts = document.getTexts() const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 0 + }) - return state + const next = state .transform() - .moveTo({ - anchorKey: first.key, - anchorOffset: 0, - focusKey: first.key, - focusOffset: 0 - }) + .moveTo(range) .addMark('bold') .insertText('a') .apply() + + assert.deepEqual(next.selection.toJS(), range.moveForward().toJS()) + + return next } diff --git a/test/transforms/fixtures/add-mark/existing-marks/index.js b/test/transforms/fixtures/add-mark/existing-marks/index.js index c3c52afbf..585286549 100644 --- a/test/transforms/fixtures/add-mark/existing-marks/index.js +++ b/test/transforms/fixtures/add-mark/existing-marks/index.js @@ -1,17 +1,24 @@ +import assert from 'assert' + export default function (state) { const { document, selection } = state const texts = document.getTexts() const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 2 + }) - return state + const next = state .transform() - .moveTo({ - anchorKey: first.key, - anchorOffset: 0, - focusKey: first.key, - focusOffset: 2 - }) + .moveTo(range) .addMark('bold') .apply() + + assert.deepEqual(next.selection.toJS(), range.toJS()) + + return next } diff --git a/test/transforms/fixtures/add-mark/first-character/index.js b/test/transforms/fixtures/add-mark/first-character/index.js index f5e846256..ab77c1401 100644 --- a/test/transforms/fixtures/add-mark/first-character/index.js +++ b/test/transforms/fixtures/add-mark/first-character/index.js @@ -1,17 +1,24 @@ +import assert from 'assert' + export default function (state) { const { document, selection } = state const texts = document.getTexts() const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 1 + }) - return state + const next = state .transform() - .moveTo({ - anchorKey: first.key, - anchorOffset: 0, - focusKey: first.key, - focusOffset: 1 - }) + .moveTo(range) .addMark('bold') .apply() + + assert.deepEqual(next.selection.toJS(), range.toJS()) + + return next } diff --git a/test/transforms/fixtures/add-mark/last-character/index.js b/test/transforms/fixtures/add-mark/last-character/index.js index 2d8ad9df4..cbf7fc1f2 100644 --- a/test/transforms/fixtures/add-mark/last-character/index.js +++ b/test/transforms/fixtures/add-mark/last-character/index.js @@ -1,17 +1,24 @@ +import assert from 'assert' + export default function (state) { const { document, selection } = state const texts = document.getTexts() const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: first.length - 1, + focusKey: first.key, + focusOffset: first.length + }) - return state + const next = state .transform() - .moveTo({ - anchorKey: first.key, - anchorOffset: first.length - 1, - focusKey: first.key, - focusOffset: first.length - }) + .moveTo(range) .addMark('bold') .apply() + + assert.deepEqual(next.selection.toJS(), range.toJS()) + + return next } diff --git a/test/transforms/fixtures/add-mark/middle-character/index.js b/test/transforms/fixtures/add-mark/middle-character/index.js index c99300d9a..e322723f4 100644 --- a/test/transforms/fixtures/add-mark/middle-character/index.js +++ b/test/transforms/fixtures/add-mark/middle-character/index.js @@ -1,17 +1,24 @@ +import assert from 'assert' + export default function (state) { const { document, selection } = state const texts = document.getTexts() const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 1, + focusKey: first.key, + focusOffset: 2 + }) - return state + const next = state .transform() - .moveTo({ - anchorKey: first.key, - anchorOffset: 1, - focusKey: first.key, - focusOffset: 2 - }) + .moveTo(range) .addMark('bold') .apply() + + assert.deepEqual(next.selection.toJS(), range.toJS()) + + return next } diff --git a/test/transforms/fixtures/add-mark/whole-word/index.js b/test/transforms/fixtures/add-mark/whole-word/index.js index 5ae0e566b..c709ce115 100644 --- a/test/transforms/fixtures/add-mark/whole-word/index.js +++ b/test/transforms/fixtures/add-mark/whole-word/index.js @@ -1,17 +1,24 @@ +import assert from 'assert' + export default function (state) { const { document, selection } = state const texts = document.getTexts() const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: first.length + }) - return state + const next = state .transform() - .moveTo({ - anchorKey: first.key, - anchorOffset: 0, - focusKey: first.key, - focusOffset: first.length - }) + .moveTo(range) .addMark('bold') .apply() + + assert.deepEqual(next.selection.toJS(), range.toJS()) + + return next } diff --git a/test/transforms/fixtures/add-mark/with-mark-object/index.js b/test/transforms/fixtures/add-mark/with-mark-object/index.js index 6b8ba9f19..a42f8626a 100644 --- a/test/transforms/fixtures/add-mark/with-mark-object/index.js +++ b/test/transforms/fixtures/add-mark/with-mark-object/index.js @@ -1,22 +1,28 @@ import { Mark } from '../../../../..' +import assert from 'assert' export default function (state) { const { document, selection } = state const texts = document.getTexts() const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 1 + }) - return state + const next = state .transform() - .moveTo({ - anchorKey: first.key, - anchorOffset: 0, - focusKey: first.key, - focusOffset: 1 - }) + .moveTo(range) .addMark(Mark.create({ type: 'bold', data: { key: 'value' } })) .apply() + + assert.deepEqual(next.selection.toJS(), range.toJS()) + + return next } diff --git a/test/transforms/fixtures/add-mark/with-plain-object/index.js b/test/transforms/fixtures/add-mark/with-plain-object/index.js index 587103e6d..e0a9401b3 100644 --- a/test/transforms/fixtures/add-mark/with-plain-object/index.js +++ b/test/transforms/fixtures/add-mark/with-plain-object/index.js @@ -1,20 +1,27 @@ +import assert from 'assert' + export default function (state) { const { document, selection } = state const texts = document.getTexts() const first = texts.first() + const range = selection.merge({ + anchorKey: first.key, + anchorOffset: 0, + focusKey: first.key, + focusOffset: 1 + }) - return state + const next = state .transform() - .moveTo({ - anchorKey: first.key, - anchorOffset: 0, - focusKey: first.key, - focusOffset: 1 - }) + .moveTo(range) .addMark({ type: 'bold', data: { key: 'value' } }) .apply() + + assert.deepEqual(next.selection.toJS(), range.toJS()) + + return next }