From 93c150884169a99208f24b387fc94f61ba259a9f Mon Sep 17 00:00:00 2001 From: David Worms Date: Tue, 23 Feb 2021 16:04:49 +0100 Subject: [PATCH] fix(core): siblings initialized as empty array --- packages/core/lib/plugins/history.js | 3 +++ packages/core/src/plugins/history.coffee | 1 + packages/core/test/plugins/history.coffee | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/packages/core/lib/plugins/history.js b/packages/core/lib/plugins/history.js index 6c234ed6f..a59fd0481 100644 --- a/packages/core/lib/plugins/history.js +++ b/packages/core/lib/plugins/history.js @@ -6,6 +6,9 @@ module.exports = { return async function() { action = (await handler.call(null, ...arguments)); action.children = []; + if (action.siblings == null) { + action.siblings = []; + } if (action.parent) { action.siblings = action.parent.children; } diff --git a/packages/core/src/plugins/history.coffee b/packages/core/src/plugins/history.coffee index ac6f2bb69..9e52c766e 100644 --- a/packages/core/src/plugins/history.coffee +++ b/packages/core/src/plugins/history.coffee @@ -7,6 +7,7 @@ module.exports = -> action = await handler.call null, ...arguments action.children = [] + action.siblings ?= [] action.siblings = action.parent.children if action.parent action.sibling = action.siblings.slice(-1)[0] if action.parent action diff --git a/packages/core/test/plugins/history.coffee b/packages/core/test/plugins/history.coffee index 83079e74e..4a7a887aa 100644 --- a/packages/core/test/plugins/history.coffee +++ b/packages/core/test/plugins/history.coffee @@ -20,6 +20,10 @@ describe 'plugins.history', -> .should.be.resolvedWith 'mayday' describe 'siblings', -> + + it 'start with empty array', -> + nikita ({siblings}) -> + siblings.should.eql [] it 'get previous action', -> nikita.call ({context}) ->