@@ -64,13 +64,13 @@ describe('ShallowTraversal', () => {
6464 const node = ( < div onChange = { noop } title = "foo" /> ) ;
6565
6666 expect ( nodeHasProperty ( node , 'onChange' ) ) . to . equal ( true ) ;
67- expect ( nodeHasProperty ( node , 'title' , 'foo' ) ) . to . equal ( true ) ;
67+ expect ( nodeHasProperty ( node , 'title' , '" foo" ' ) ) . to . equal ( true ) ;
6868 } ) ;
6969
7070 it ( 'should not match on html attributes' , ( ) => {
7171 const node = ( < div htmlFor = "foo" /> ) ;
7272
73- expect ( nodeHasProperty ( node , 'for' , 'foo' ) ) . to . equal ( false ) ;
73+ expect ( nodeHasProperty ( node , 'for' , '" foo" ' ) ) . to . equal ( false ) ;
7474 } ) ;
7575
7676 it ( 'should not find undefined properties' , ( ) => {
@@ -79,6 +79,35 @@ describe('ShallowTraversal', () => {
7979 expect ( nodeHasProperty ( node , 'title' ) ) . to . equal ( false ) ;
8080 } ) ;
8181
82+ it ( 'should parse false as a literal' , ( ) => {
83+ const node = ( < div foo = { false } /> ) ;
84+
85+ expect ( nodeHasProperty ( node , 'foo' , 'false' ) ) . to . equal ( true ) ;
86+ } ) ;
87+
88+ it ( 'should parse false as a literal' , ( ) => {
89+ const node = ( < div foo /> ) ;
90+
91+ expect ( nodeHasProperty ( node , 'foo' , 'true' ) ) . to . equal ( true ) ;
92+ } ) ;
93+
94+ it ( 'should parse numbers as numeric literals' , ( ) => {
95+ expect ( nodeHasProperty ( < div foo = { 2.3 } /> , 'foo' , '2.3' ) ) . to . equal ( true ) ;
96+ expect ( nodeHasProperty ( < div foo = { 2 } /> , 'foo' , '2' ) ) . to . equal ( true ) ;
97+ expect ( ( ) => nodeHasProperty ( < div foo = { 2 } /> , 'foo' , '2abc' ) ) . to . throw ( ) ;
98+ expect ( ( ) => nodeHasProperty ( < div foo = { 2 } /> , 'foo' , 'abc2' ) ) . to . throw ( ) ;
99+ expect ( nodeHasProperty ( < div foo = { - 2 } /> , 'foo' , '-2' ) ) . to . equal ( true ) ;
100+ expect ( nodeHasProperty ( < div foo = { 2e8 } /> , 'foo' , '2e8' ) ) . to . equal ( true ) ;
101+ expect ( nodeHasProperty ( < div foo = { Infinity } /> , 'foo' , 'Infinity' ) ) . to . equal ( true ) ;
102+ expect ( nodeHasProperty ( < div foo = { - Infinity } /> , 'foo' , '-Infinity' ) ) . to . equal ( true ) ;
103+ } ) ;
104+
105+ it ( 'should throw when un unquoted string is passed in' , ( ) => {
106+ const node = ( < div title = "foo" /> ) ;
107+
108+ expect ( ( ) => nodeHasProperty ( node , 'title' , 'foo' ) ) . to . throw ( ) ;
109+ } ) ;
110+
82111 } ) ;
83112
84113 describe ( 'treeForEach' , ( ) => {
0 commit comments