UNPKG

wix-storybook-utils

Version:

Utilities for automated component documentation within Storybook

36 lines 1.8 kB
import { mount } from 'enzyme'; import { SIBLINGS, sectionWithSiblings } from '.'; import Markdown from '../../Markdown'; import * as sectionBuilders from '../'; describe('sectionWithSiblings', function () { ['title', 'header', 'example'].map(function (section) { it("should not render siblings for ".concat(section, " section"), function () { var expectation = "".concat(section, " without siblings"); var rendered = mount(sectionWithSiblings(sectionBuilders[section]({ pretitle: 'i', title: 'should', subtitle: 'not', description: 'show', }), expectation)); SIBLINGS.map(function (sibling) { expect(rendered.find(".".concat(sibling)).exists()).toBe(false); }); }); }); describe('ImportExampleSection', function () { it('should have `Import` when `title` is undefined', function () { var source = 'best test code'; var makeSection = function (sectionConfig) { return mount(sectionWithSiblings(sectionBuilders.importExample(sectionConfig), 'dummy content')); }; var withTitle = makeSection({ title: 'hey there', source: source }); var withoutTitle = makeSection(sectionBuilders.importExample({ source: source })); var withoutTitleShorthand = makeSection(source); // this also tests that Markdown is used! expect(withTitle.find(Markdown).prop('source')).toEqual('hey there'); expect(withoutTitle.find(Markdown).prop('source')).toEqual('Import'); expect(withoutTitleShorthand.find(Markdown).prop('source')).toEqual('Import'); }); }); }); //# sourceMappingURL=index.test.js.map