From af6b0e0388597b24c259a593b0372d4f764d97a3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samy=20Pess=C3=A9?= Date: Tue, 1 Nov 2016 11:53:36 +0100 Subject: [PATCH] Add unit test for undo of setNodeByKey --- .../on-history/undo/set-node-data/index.js | 17 +++++++++++++++++ .../on-history/undo/set-node-data/input.yaml | 7 +++++++ .../on-history/undo/set-node-data/output.yaml | 7 +++++++ 3 files changed, 31 insertions(+) create mode 100644 test/transforms/fixtures/on-history/undo/set-node-data/index.js create mode 100644 test/transforms/fixtures/on-history/undo/set-node-data/input.yaml create mode 100644 test/transforms/fixtures/on-history/undo/set-node-data/output.yaml diff --git a/test/transforms/fixtures/on-history/undo/set-node-data/index.js b/test/transforms/fixtures/on-history/undo/set-node-data/index.js new file mode 100644 index 000000000..0c2776b77 --- /dev/null +++ b/test/transforms/fixtures/on-history/undo/set-node-data/index.js @@ -0,0 +1,17 @@ + +export default function (state) { + const { document } = state + + const next = state + .transform() + .setNodeByKey(document.nodes.first().key, { + data: { src: 'world.png' } + }) + .apply() + + .transform() + .undo() + .apply() + + return next +} diff --git a/test/transforms/fixtures/on-history/undo/set-node-data/input.yaml b/test/transforms/fixtures/on-history/undo/set-node-data/input.yaml new file mode 100644 index 000000000..4a0c147b9 --- /dev/null +++ b/test/transforms/fixtures/on-history/undo/set-node-data/input.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: image + isVoid: true + data: + src: hello.png diff --git a/test/transforms/fixtures/on-history/undo/set-node-data/output.yaml b/test/transforms/fixtures/on-history/undo/set-node-data/output.yaml new file mode 100644 index 000000000..4a0c147b9 --- /dev/null +++ b/test/transforms/fixtures/on-history/undo/set-node-data/output.yaml @@ -0,0 +1,7 @@ + +nodes: + - kind: block + type: image + isVoid: true + data: + src: hello.png