wix-storybook-utils
Version:
Utilities for automated component documentation within Storybook
60 lines • 2.56 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
var tslib_1 = require("tslib");
var React = tslib_1.__importStar(require("react"));
var enzyme_1 = require("enzyme");
var deep_assign_1 = require("../../test/utils/deep-assign");
var Markdown_1 = tslib_1.__importDefault(require("../Markdown"));
var AutoExample_1 = tslib_1.__importDefault(require("../AutoExample"));
var index_1 = tslib_1.__importDefault(require("./index"));
var AutoTestkit_1 = require("../AutoTestkit");
var default_1 = /** @class */ (function () {
function default_1() {
var _this = this;
this.defaultProps = {
metadata: {
props: {},
},
config: {},
component: function () { return React.createElement("div", null); },
componentProps: {},
exampleProps: {},
examples: null,
};
this.when = {
created: function (props) {
return (_this.component = (0, enzyme_1.mount)(React.createElement(index_1.default, tslib_1.__assign({}, (0, deep_assign_1.deepAssign)(_this.defaultProps, props)))));
},
};
this.openTab = function (title) {
return _this.component.find("li[data-hook=\"".concat(title, "\"]")).simulate('click');
};
this.debug = function () { return console.log(_this.component.debug()); };
this.get = {
readme: function () {
return _this.component
.find('[data-hook="metadata-readme-markdown"]')
.prop('source');
},
import: function () {
return _this.component
.find('[data-hook="metadata-import-markdown"]')
.prop('source');
},
codeBlock: function () {
return _this.component.find('[data-hook="metadata-codeblock"]').find(Markdown_1.default);
},
autoExample: function () { return _this.component.find(AutoExample_1.default); },
api: {
markdown: function () { return _this.component.find('[data-hook="api-markdown"]'); },
},
testkit: {
markdown: function () { return _this.component.find('[data-hook="testkit-markdown"]'); },
autoGenerated: function () { return _this.component.find(AutoTestkit_1.AutoTestkit); },
},
};
}
return default_1;
}());
exports.default = default_1;
//# sourceMappingURL=testkit.js.map