gengyang 64c9daa1f4 refactor: 💡 refactor with react-docgen
BREAKING CHANGE: 🧨 use react-docgen to replace parser
2020-03-16 16:32:41 +08:00

41 lines
1.4 KiB
TypeScript

import test from 'ava';
import ReactParser from '../../src/parser/ReactParser';
import Scanner from '../../src/scanner/Scanner';
import { IMaterializeOptions, IMaterialParsedModel } from '../../src/types';
import { getFromFixtures } from '../helpers';
const multiExportedComptPath = getFromFixtures('multiple-exported-component');
const singleExportedComptPath = getFromFixtures('single-exported-component');
// test.serial('parse es6 multiple exported component by local', async t => {
// const options: IMaterializeOptions = {
// cwd: multiExportedComptPath,
// entry: multiExportedComptPath,
// accesser: 'local',
// isExportedAsMultiple: true,
// };
// const scanner = new Scanner(options);
// const scanModel = await scanner.scan();
// const parser = new ReactParser(options);
// const actual: IMaterialParsedModel[] = await parser.parse(scanModel);
// t.snapshot(actual);
// });
test.serial('parse es6 single exported component by local', async t => {
const options: IMaterializeOptions = {
cwd: singleExportedComptPath,
entry: singleExportedComptPath,
accesser: 'local',
isExportedAsMultiple: false,
};
const scanner = new Scanner(options);
const scanModel = await scanner.scan();
const parser = new ReactParser(options);
const actual: IMaterialParsedModel[] = await parser.parse(scanModel);
t.snapshot(actual);
});