Skip to content

Commit

Permalink
Merge pull request #3023 from tniezg/test-display-safety-net
Browse files Browse the repository at this point in the history
Added safety net preventing storybook Jest addon from throwing.
  • Loading branch information
Hypnosphi authored Feb 19, 2018
2 parents c8d4fbf + 6e33fd2 commit 4f545e8
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions addons/jest/src/components/Result.js
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,13 @@ const createSubgroup = (acc, item, i, list) => {

// on last iteration inject at detected injectionpoint, and group
if (i === list.length - 1) {
// Provide a "safety net" when Jest returns a partially recognized "group"
// (recognized by acc.startTrigger but acc.endTrigger was never found) and
// it's the only group in output for a test result. In that case, acc.list
// will be empty, so return whatever was found, even if it will be unstyled
// and prevent next createSubgroup calls from throwing due to empty lists.
acc.list.push(null);

return acc.list.reduce((eacc, el, ei) => {
switch (true) {
case acc.injectionPoint === 0 && ei === 0: {
Expand Down

0 comments on commit 4f545e8

Please sign in to comment.