{
7 | import('./fake-dialog-box.js')
8 | .then(dialogBox => {
9 | dialogBox.open();
10 | })
11 | .catch(error => {
12 | /* Error handling */
13 | })
14 | }} />;
15 | }
16 | }
17 |
--------------------------------------------------------------------------------
/tests/cli-test.ts:
--------------------------------------------------------------------------------
1 | // tslint:disable:no-implicit-dependencies
2 | import test from 'ava';
3 | import execa from 'execa';
4 | import * as fs from 'fs';
5 |
6 | function normalize(input: string): string {
7 | return input.replace(/\s+/g, ' ').replace(/ => /g, '=>');
8 | }
9 |
10 | test('cli should read from stdin', async (t) => {
11 | const expected = fs
12 | .readFileSync('./tests/import-react-component.d.ts')
13 | .toString();
14 |
15 | const result = await execa(
16 | `cat ./tests/import-react-component.jsx |${process.argv[0]} ./cli.js --module-name component`,
17 | { shell: true }
18 | );
19 |
20 | t.is(normalize(result.stdout), normalize(expected));
21 | });
22 |
23 | test('cli should read from file', async (t) => {
24 | const expected = fs
25 | .readFileSync('./tests/import-react-component.d.ts')
26 | .toString();
27 |
28 | const result = await execa(
29 | `${process.argv[0]} ./cli.js --module-name component --file ./tests/import-react-component.jsx`,
30 | { shell: true }
31 | );
32 |
33 | t.is(normalize(result.stdout), normalize(expected));
34 | });
35 |
--------------------------------------------------------------------------------
/tests/component-without-proptypes.d.ts:
--------------------------------------------------------------------------------
1 | declare module 'component' {
2 | import * as React from 'react';
3 |
4 | export interface TestProps {
5 | }
6 |
7 | export default class Test extends React.Component