wix-storybook-utils
Version:
Utilities for automated component documentation within Storybook
106 lines • 3.26 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var drivers_1 = require("./drivers");
describe('FieldsDocumentation', function () {
var driver = (0, drivers_1.createFieldsDocumentationDriver)();
it('renders primitives', function () {
var units = [
{
type: 'value',
name: 'not-a-function',
},
{
type: 'object',
name: 'not-a-function-either',
},
{
type: 'error',
name: 'failure during parsing',
},
];
driver.create({ units: units });
expect(driver.get.count()).toBe(units.length);
units.forEach(function (unit, i) {
expect(driver.get.at(i).get.name()).toBe(unit.name);
});
});
it('renders functions', function () {
var units = [
{
type: 'value',
name: 'not-a-function',
},
{
type: 'value',
name: 'not-a-function2',
},
];
driver.create({ units: units });
expect(driver.get.count()).toBe(units.length);
units.forEach(function (unit, index) {
expect(driver.get.at(index).get.name()).toBe(unit.name);
});
});
it('renders combinations of values and functions', function () {
var units = [
{
type: 'value',
name: 'not-a-function',
},
{
type: 'function',
args: [],
name: 'func',
},
];
driver.create({ units: units });
expect(driver.get.count()).toBe(units.length);
units.forEach(function (unit, index) {
expect(driver.get.at(index).get.name()).toBe(unit.name);
});
});
it('should not fail given invalid unit type', function () {
var units = [
{
type: 'notFittingType',
name: 'no name',
},
];
var spy = jest.fn();
driver.create({ units: units }, spy);
expect(spy).not.toHaveBeenCalled();
});
it('has a property header', function () {
var units = [
{
type: 'value',
name: 'not-a-function',
},
{
type: 'function',
args: [],
name: 'func',
},
];
driver.create({ units: units });
expect(driver.get.header('property').tag()).toBe('th');
expect(driver.get.header('property').text()).toBe('Property');
});
it('has a description header', function () {
var units = [
{
type: 'value',
name: 'not-a-function',
},
{
type: 'function',
args: [],
name: 'func',
},
];
driver.create({ units: units });
expect(driver.get.header('description').tag()).toBe('th');
expect(driver.get.header('description').text()).toBe('Description');
});
});
//# sourceMappingURL=fields-documentation.test.js.map