From 5fab99eaf4ac7ae606356ff0a8662f4ed373ef13 Mon Sep 17 00:00:00 2001 From: muzea Date: Tue, 25 Sep 2018 14:27:27 +0800 Subject: [PATCH] test: allow users to set additional babylon plugins --- tests/babylon-plugin.d.ts | 12 ++++++++++++ tests/babylon-plugin.jsx | 16 ++++++++++++++++ tests/parsing-test.ts | 9 +++++++++ 3 files changed, 37 insertions(+) create mode 100644 tests/babylon-plugin.d.ts create mode 100644 tests/babylon-plugin.jsx diff --git a/tests/babylon-plugin.d.ts b/tests/babylon-plugin.d.ts new file mode 100644 index 00000000..22f41aa5 --- /dev/null +++ b/tests/babylon-plugin.d.ts @@ -0,0 +1,12 @@ +declare module 'Component' { + import * as React from 'react'; + + export interface ComponentProps { + } + + export default class Component extends React.Component { + render(): JSX.Element; + + } + +} diff --git a/tests/babylon-plugin.jsx b/tests/babylon-plugin.jsx new file mode 100644 index 00000000..3f0242df --- /dev/null +++ b/tests/babylon-plugin.jsx @@ -0,0 +1,16 @@ +import * as React from 'react'; + +export default class Component extends React.PureComponent { + + render() { + return

{ + import('./fake-dialog-box.js') + .then(dialogBox => { + dialogBox.open(); + }) + .catch(error => { + /* Error handling */ + }) + }} />; + } +} diff --git a/tests/parsing-test.ts b/tests/parsing-test.ts index 43fd2e62..185d837b 100644 --- a/tests/parsing-test.ts +++ b/tests/parsing-test.ts @@ -123,3 +123,12 @@ test('Parsing should suppport custom eol style', t => { fs.readFileSync(path.join(basedir, 'pure-component.d.ts')).toString().replace('\r\n', '\n') ); }); +test('Parsing should suppport users to set additional babylon plugins', t => { + compare( + t, + 'Component', + 'babylon-plugin.jsx', + 'babylon-plugin.d.ts', + { babylonPlugins: ['dynamicImport'] } + ); +});