@@ -18,7 +18,7 @@ test.afterEach(() => {
1818 console . error = orignalConsoleError ;
1919} ) ;
2020
21- test ( 'In case of error during type inference the error information should be retained' , t => {
21+ test ( 'In case of error during shape type inference the error information should be retained' , t => {
2222 react2dts . generateFromSource ( null , `
2323 import React from 'react';
2424
@@ -32,3 +32,48 @@ test('In case of error during type inference the error information should be ret
3232 const idx = args . indexOf ( 'Line 6: someShape: React.PropTypes.shape(shape)' ) ;
3333 t . is ( idx , 1 ) ;
3434} ) ;
35+
36+ test ( 'In case of error during enum type inference the error information should be retained' , t => {
37+ react2dts . generateFromSource ( null , `
38+ import React from 'react';
39+
40+ export class Component extends React.Component {
41+ static propTypes = {
42+ list: React.PropTypes.oneOf(list)
43+ };
44+ }
45+ ` ) ;
46+ const args = t . context . args . reduce ( ( akku : any [ ] , args : any [ ] ) => [ ...akku , ...args ] , [ ] ) ;
47+ const idx = args . indexOf ( 'Line 6: list: React.PropTypes.oneOf(list)' ) ;
48+ t . is ( idx , 1 ) ;
49+ } ) ;
50+
51+ test ( 'In case of error during enum value creation inference the error information should be retained' , t => {
52+ react2dts . generateFromSource ( null , `
53+ import React from 'react';
54+
55+ export class Component extends React.Component {
56+ static propTypes = {
57+ list: React.PropTypes.oneOf(Object.keys(object))
58+ };
59+ }
60+ ` ) ;
61+ const args = t . context . args . reduce ( ( akku : any [ ] , args : any [ ] ) => [ ...akku , ...args ] , [ ] ) ;
62+ const idx = args . indexOf ( 'Line 6: list: React.PropTypes.oneOf(Object.keys(object))' ) ;
63+ t . is ( idx , 1 ) ;
64+ } ) ;
65+
66+ test ( 'In case of error during shape type inference the error information should be retained' , t => {
67+ react2dts . generateFromSource ( null , `
68+ import React from 'react';
69+
70+ export class Component extends React.Component {
71+ static propTypes = {
72+ shape: React.PropTypes.shape(some.shape)
73+ };
74+ }
75+ ` ) ;
76+ const args = t . context . args . reduce ( ( akku : any [ ] , args : any [ ] ) => [ ...akku , ...args ] , [ ] ) ;
77+ const idx = args . indexOf ( 'Line 6: shape: React.PropTypes.shape(some.shape)' ) ;
78+ t . is ( idx , 1 ) ;
79+ } ) ;
0 commit comments