wix-storybook-utils
Version:
Utilities for automated component documentation within Storybook
23 lines • 1.54 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
var doctor_code_1 = require("./doctor-code");
describe('transformCode', function () {
it('should remove import statement', function () {
var source = 'import Thing from "thong";';
expect((0, doctor_code_1.transformCode)(source)).toEqual('');
});
it('should remove export statement', function () {
var source = 'export const it = "ution"';
expect((0, doctor_code_1.transformCode)(source)).toEqual('');
});
it('should remove require statement', function () {
var source = 'const candidate = require("ment")';
expect((0, doctor_code_1.transformCode)(source)).toEqual('');
});
it('should transform class properties', function () {
var source = "\nimport React from \"react\";\nimport { Lorem } from \"somewhere\";\n\nclass Component extends React.Component {\n state = { value: \"test\" };\n onClick = event => this.setState({ value: 'clicked' });\n render() {\n return <button onClick={this.onClick} />;\n }\n}";
var expectation = "class Component extends React.Component {\n constructor(...args) {\n super(...args);\n this.state = {\n value: \"test\"\n };\n\n this.onClick = event => this.setState({\n value: 'clicked'\n });\n }\n\n render() {\n return <button onClick={this.onClick} />;\n }\n\n}";
expect((0, doctor_code_1.transformCode)(source)).toEqual(expectation);
});
});
//# sourceMappingURL=doctor-code.spec.js.map