wix-storybook-utils
Version:
Utilities for automated component documentation within Storybook
66 lines • 2.61 kB
JavaScript
import { deepAssign } from '../../test/utils/deep-assign';
import { SectionType } from '../typings/story-section';
import { createDefaultSections } from './create-default-sections';
import { header } from '.';
var storyConfig = function (config) {
if (config === void 0) { config = {}; }
return deepAssign({
config: {},
metadata: {},
exampleImport: {},
examples: {},
}, config);
};
describe('createDefaultSection', function () {
describe('header section', function () {
it('should be first one', function () {
var firstSection = createDefaultSections(storyConfig())[0];
expect(firstSection.type).toEqual(SectionType.Header);
});
it('should merge config from sections', function () {
var headerConfig = {
issueUrl: 'hello',
sourceUrl: 'from',
component: 'test',
};
var firstSection = createDefaultSections(storyConfig({ sections: [header(headerConfig)] }))[0];
expect(firstSection).toEqual(expect.objectContaining(headerConfig));
});
it('should display sourceUrl for component stories', function () {
var config = storyConfig({
metadata: {
displayName: 'name',
},
config: {
repoBaseURL: 'base/',
},
});
var firstSection = createDefaultSections(config)[0];
expect(firstSection.sourceUrl).toEqual('base/name');
});
describe('title', function () {
it('should be taken from displayName', function () {
var displayName = 'best name';
var config = storyConfig({
metadata: {
displayName: displayName,
},
});
var firstSection = createDefaultSections(config)[0];
expect(firstSection.title).toEqual(displayName);
});
it('should prioritize storyName', function () {
var storyName = 'besterer name';
var config = storyConfig({
storyName: storyName,
metadata: {
displayName: 'i should be ignored',
},
});
var firstSection = createDefaultSections(config)[0];
expect(firstSection.title).toEqual(storyName);
});
});
});
});
//# sourceMappingURL=create-default-sections.test.js.map