Skip to content

Commit

Permalink
nesting ability added
Browse files Browse the repository at this point in the history
  • Loading branch information
CurtisHumphrey committed Sep 7, 2017
1 parent bb7c787 commit 8983919
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions src/preview.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import addons from '@storybook/addons';
import { EVENT_ID } from './';

let currentStory = "";
const subStory = [];
const results = {};
const beforeEachFunc = {};
const afterFunc = {};
Expand All @@ -14,14 +15,23 @@ export function specs(specs) {
}

export const describe = (storyName, func) => {
currentStory = storyName;
results[currentStory] = { goodResults: [], wrongResults: [] };
let first_describe = false
if (currentStory === "") {
first_describe = true
currentStory = storyName;
results[currentStory] = { goodResults: [], wrongResults: [] };
} else {
subStory.push(storyName)
}
func();
if(afterFunc[currentStory]) afterFunc[currentStory]();
subStory.pop()
if (first_describe) currentStory = ""
return storyName;
};

export const it = function(desc, func) {
if (subStory.length) desc = subStory.join(" > ") + ": " + desc
const storyName = currentStory;

const pushGoodResult = () => {
Expand Down

0 comments on commit 8983919

Please sign in to comment.