This repository was archived by the owner on Nov 27, 2023. It is now read-only.
File tree Expand file tree Collapse file tree 3 files changed +92
-3
lines changed Expand file tree Collapse file tree 3 files changed +92
-3
lines changed Original file line number Diff line number Diff line change 4040 "@knisterpeter/standard-tslint" : " ^1.6.0" ,
4141 "@types/babel-generator" : " ^6.25.0" ,
4242 "@types/diff" : " ^3.2.2" ,
43+ "@types/execa" : " 0.8.0" ,
4344 "@types/node" : " ^8.0.50" ,
4445 "@types/prop-types" : " 15.5.2" ,
4546 "@types/react" : " ^16.0.21" ,
5253 "coveralls" : " ^3.0.0" ,
5354 "cz-conventional-changelog" : " 2.1.0" ,
5455 "diff" : " 3.4.0" ,
56+ "execa" : " 0.8.0" ,
5557 "nyc" : " 11.3.0" ,
5658 "prop-types" : " 15.6.0" ,
5759 "react" : " ^16.0.0" ,
Original file line number Diff line number Diff line change 1+ import test from 'ava' ;
2+ import { shell } from 'execa' ;
3+ import * as fs from 'fs' ;
4+
5+ function normalize ( input : string ) : string {
6+ return input
7+ . replace ( / \s + / g, ' ' )
8+ . replace ( / = > / g, '=>' ) ;
9+ }
10+
11+ test ( 'cli should read from stdin' , async t => {
12+ const expected = fs . readFileSync ( './tests/import-react-component.d.ts' ) . toString ( ) ;
13+
14+ const result = await shell (
15+ `cat ./tests/import-react-component.jsx |${ process . argv [ 0 ] } ./cli.js --module-name component` ) ;
16+
17+ t . is ( normalize ( result . stdout ) , normalize ( expected ) ) ;
18+ } ) ;
19+
20+ test ( 'cli should read from file' , async t => {
21+ const expected = fs . readFileSync ( './tests/import-react-component.d.ts' ) . toString ( ) ;
22+
23+ const result = await shell (
24+ `${ process . argv [ 0 ] } ./cli.js --module-name component --file ./tests/import-react-component.jsx` ) ;
25+
26+ t . is ( normalize ( result . stdout ) , normalize ( expected ) ) ;
27+ } ) ;
You can’t perform that action at this time.
0 commit comments