wix-storybook-utils
Version:
Utilities for automated component documentation within Storybook
100 lines • 4.76 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var story_page_driver_1 = require("./story-page.driver");
var react_1 = tslib_1.__importDefault(require("react"));
describe('StoryPage', function () {
it('should render simple storyPage', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)(), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given feature example should render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)()
.addExamples({ _random: '</div>' })
.addFeatureExample({
title: 'title',
description: 'description',
example: '_random',
}), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given feature example without code example should not render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addFeatureExample({
title: 'title',
description: 'description',
example: '_random',
}), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given feature example as empty', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addFeatureExample([]), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given common use case example', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)()
.addExamples({ _random: '</div>' })
.addCommonUseCasesExample({
title: 'title',
description: 'description',
example: '_random',
}), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given common use case example as empty should not render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addCommonUseCasesExample([]), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given description should render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addDescription('Hello'), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given dodont should render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addDoDont({
do: ['one'],
dont: ['two'],
}), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given dodont as empty arrays should not render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addDoDont({
do: [],
dont: [],
}), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given includedComponents as empty array should not render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addIncludedComponents([]), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given includedComponents should render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addIncludedComponents([
{ category: 'Category', title: 'FirstComponent', optional: true },
{ category: 'Category', title: 'SecondComponent' },
]), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given demo should render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addDemo(react_1.default.createElement("div", null, "This is test")), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given demo as demo should render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addDemo('<div>This is test</div>'), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given empty demo should not render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)().addDemo(null), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
it('given an example with wide: true should render it', function () {
var _a = (0, story_page_driver_1.createStoryBuilder)()
.addExamples({ _random: '</div>' })
.addFeatureExample({
title: 'title',
description: 'description',
example: '_random',
wide: true,
}), input = _a.input, output = _a.output;
expect(input).toBe(output);
});
});
//# sourceMappingURL=story-page.test.js.map