From 3e2fa37250e60f8ed7dfa6e60f8f19045d0dcfd9 Mon Sep 17 00:00:00 2001
From: squidfunk <martin.donath@squidfunk.com>
Date: Thu, 9 Feb 2017 17:49:13 +0100
Subject: [PATCH] Fixed case where there were no states defined

---
 .travis.yml                  |  2 +-
 tests/visual/helpers/spec.js | 27 ++++++++++++++-------------
 2 files changed, 15 insertions(+), 14 deletions(-)

diff --git a/.travis.yml b/.travis.yml
index 5bc0f66e..3f749083 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -31,7 +31,7 @@ node_js:
 matrix:
   include:
     - node_js: 7
-      script: yarn run test:visual:run
+      script: yarn run test:visual:run --no-clean
 
 # Install a C++11 compatible compiler
 addons:
diff --git a/tests/visual/helpers/spec.js b/tests/visual/helpers/spec.js
index 2ab6eead..0c41dacf 100644
--- a/tests/visual/helpers/spec.js
+++ b/tests/visual/helpers/spec.js
@@ -136,42 +136,43 @@ const generate = (dirname, components) => {
         suite.setCaptureElements(component.capture)
 
       /* Generate a subsuite for every state */
-      for (const state of component.states) {
+      const states = component.states || [{ name: "", wait: 0 }]
+      for (const state of states) {
         const test = subsuite => {
 
-          /* Resolve and apply relevant breakpoints */
+            /* Resolve and apply relevant breakpoints */
           const breakpoints = resolve(config.breakpoints, component.break)
           for (const breakpoint of breakpoints) {
             subsuite.capture(`@${breakpoint.name}`, actions => {
 
-              /* Set window size according to breakpoint */
+                /* Set window size according to breakpoint */
               actions.setWindowSize(
-                breakpoint.size.width, breakpoint.size.height)
+                  breakpoint.size.width, breakpoint.size.height)
 
-              /* Add the name as a CSS class to the captured element */
+                /* Add the name as a CSS class to the captured element */
               if (state.name)
                 actions.executeJS(new Function(`
-                  document.querySelector(
-                    "${component.capture}"
-                  ).classList.add("${state.name}")
-                `))
+                    document.querySelector(
+                      "${component.capture}"
+                    ).classList.add("${state.name}")
+                  `))
 
-              /* Execute function inside an IIFE */
+                /* Execute function inside an IIFE */
               if (state.exec)
                 actions.executeJS(new Function(`(${state.exec})()`))
 
-              /* Wait the specified time before taking a screenshot */
+                /* Wait the specified time before taking a screenshot */
               if (state.wait)
                 actions.wait(state.wait)
             })
           }
         }
 
-        /* No state sub-suite if the name is empty */
+          /* No state sub-suite if the name is empty */
         if (state.name.length > 0)
           gemini.suite(state.name, subsuite => test(subsuite))
         else
-          test(suite)
+            test(suite)
       }
 
       /* Generate sub-suites */
-- 
GitLab