diff --git a/.storybook/__tests__/sample.ci.jest.stories.js b/.storybook/__tests__/sample.ci.jest.stories.js index f85ec70..9a435e0 100644 --- a/.storybook/__tests__/sample.ci.jest.stories.js +++ b/.storybook/__tests__/sample.ci.jest.stories.js @@ -33,6 +33,12 @@ stories.add('Hello World', function () { expect(output.text()).toContain('Hello World'); }); + describe('Expects should work nexted too', () => { + it('Should have the Hello World label', function () { + expect(output.text()).toContain('Hello World'); + }); + }); + })); return helloWorldStory; }); diff --git a/.storybook/__tests__/sample.ci.mocha.stories.js b/.storybook/__tests__/sample.ci.mocha.stories.js index 4f028d7..4678b6a 100644 --- a/.storybook/__tests__/sample.ci.mocha.stories.js +++ b/.storybook/__tests__/sample.ci.mocha.stories.js @@ -37,6 +37,12 @@ stories.add('Hello World', function () { expect(output.text()).toContain('Hello World'); }); + describe('Expects should work nexted too', () => { + it('Should have the Hello World label', function () { + expect(output.text()).toContain('Hello World'); + }); + }); + })); return helloWorldStory; }); diff --git a/.storybook/__tests__/sample.stories.js b/.storybook/__tests__/sample.stories.js index 1a72840..1c05e39 100644 --- a/.storybook/__tests__/sample.stories.js +++ b/.storybook/__tests__/sample.stories.js @@ -1,7 +1,9 @@ import React from "react"; import {storiesOf, action} from '@storybook/react' import { specs, describe, it} from '../../src' -import {mount} from "enzyme"; +import Enzyme, {mount} from "enzyme" +import Adapter from "enzyme-adapter-react-16" +Enzyme.configure({ adapter: new Adapter() }); import expect from "expect"; @@ -18,6 +20,12 @@ stories.add('Hello World', function () { let output = mount(helloWorldStory); expect(output.text()).toContain('Hello Wrld'); }); + describe('Expects should work nexted too', () => { + it('Should have the Hello World label', function () { + let output = mount(helloWorldStory); + expect(output.text()).toContain('Hello Wrld'); + }); + }); it('Should have the Hello World label', function () { let output = mount(helloWorldStory); diff --git a/src/preview.js b/src/preview.js index 1ecd04b..e3438d7 100644 --- a/src/preview.js +++ b/src/preview.js @@ -2,6 +2,7 @@ import addons from '@storybook/addons'; import { EVENT_ID } from './'; let currentStory = ""; +const subStory = []; const results = {}; const beforeEachFunc = {}; const afterFunc = {}; @@ -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 = () => {