@@ -111,16 +111,6 @@ describe('getPropValue', () => {
111
111
assert . equal ( expected , actual ) ;
112
112
} ) ;
113
113
114
- it ( 'should work with a Typescript non-null assertion' , ( ) => {
115
- changePlugins ( pls => [ ...pls , 'typescript' ] ) ;
116
- const prop = extractProp ( '<div foo={bar!} />' ) ;
117
-
118
- const expected = 'bar' ;
119
- const actual = getPropValue ( prop ) ;
120
-
121
- assert . equal ( expected , actual ) ;
122
- } ) ;
123
-
124
114
it ( 'should return undefined when identifier is literally `undefined`' , ( ) => {
125
115
const prop = extractProp ( '<div foo={undefined} />' ) ;
126
116
@@ -885,4 +875,38 @@ describe('getPropValue', () => {
885
875
assert . deepEqual ( otherExpected , otherActual ) ;
886
876
} ) ;
887
877
} ) ;
878
+
879
+ describe ( 'Typescript' , ( ) => {
880
+ beforeEach ( ( ) => {
881
+ changePlugins ( pls => [ ...pls , 'typescript' ] ) ;
882
+ } ) ;
883
+
884
+ it ( 'should return string representation of variable identifier wrapped in a Typescript non-null assertion' , ( ) => {
885
+ const prop = extractProp ( '<div foo={bar!} />' ) ;
886
+
887
+ const expected = 'bar' ;
888
+ const actual = getPropValue ( prop ) ;
889
+
890
+ assert . equal ( expected , actual ) ;
891
+ } ) ;
892
+
893
+ it ( 'should return string representation of variable identifier wrapped in a deep Typescript non-null assertion' , ( ) => {
894
+ const prop = extractProp ( '<div foo={(bar!)!} />' ) ;
895
+
896
+ const expected = 'bar' ;
897
+ const actual = getPropValue ( prop ) ;
898
+
899
+ assert . equal ( expected , actual ) ;
900
+ } ) ;
901
+
902
+ it ( 'should return string representation of variable identifier wrapped in a Typescript type coercion' , ( ) => {
903
+ changePlugins ( pls => [ ...pls , 'typescript' ] ) ;
904
+ const prop = extractProp ( '<div foo={bar as any} />' ) ;
905
+
906
+ const expected = 'bar' ;
907
+ const actual = getPropValue ( prop ) ;
908
+
909
+ assert . equal ( expected , actual ) ;
910
+ } ) ;
911
+ } ) ;
888
912
} ) ;
0 commit comments