UNPKG

wix-storybook-utils

Version:

Utilities for automated component documentation within Storybook

39 lines 2.01 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); var tslib_1 = require("tslib"); var enzyme_1 = require("enzyme"); var _1 = require("."); var Markdown_1 = tslib_1.__importDefault(require("../../Markdown")); var sectionBuilders = tslib_1.__importStar(require("../")); 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 = (0, enzyme_1.mount)((0, _1.sectionWithSiblings)(sectionBuilders[section]({ pretitle: 'i', title: 'should', subtitle: 'not', description: 'show', }), expectation)); _1.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 (0, enzyme_1.mount)((0, _1.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_1.default).prop('source')).toEqual('hey there'); expect(withoutTitle.find(Markdown_1.default).prop('source')).toEqual('Import'); expect(withoutTitleShorthand.find(Markdown_1.default).prop('source')).toEqual('Import'); }); }); }); //# sourceMappingURL=index.test.js.map