@@ -65,19 +65,32 @@ describe('replaceVariables', () => {
6565 ) ;
6666 } ) ;
6767
68+ it ( 'replaces missing variable declaration with null' , ( ) => {
69+ const ast = parseValue ( '$var' ) ;
70+ const vars = testVariables ( '' , { } ) ;
71+ expect ( replaceVariables ( ast , vars ) ) . to . deep . equal ( parseValue ( 'null' ) ) ;
72+ } ) ;
73+
74+ it ( 'replaces misspelled variable declaration with null' , ( ) => {
75+ const ast = parseValue ( '$var1' ) ;
76+ const vars = testVariables ( '($var2: Int)' , { var2 : 123 } ) ;
77+ expect ( replaceVariables ( ast , vars ) ) . to . deep . equal ( parseValue ( 'null' ) ) ;
78+ } ) ;
79+
6880 it ( 'replaces missing Variables in lists with null' , ( ) => {
6981 const ast = parseValue ( '[1, $var]' ) ;
7082 expect ( replaceVariables ( ast , undefined ) ) . to . deep . equal (
7183 parseValue ( '[1, null]' ) ,
7284 ) ;
7385 } ) ;
74- } ) ;
7586
76- it ( 'omits missing Variables from objects' , ( ) => {
77- const ast = parseValue ( '{ foo: 1, bar: $var }' ) ;
78- expect ( replaceVariables ( ast , undefined ) ) . to . deep . equal (
79- parseValue ( '{ foo: 1 }' ) ,
80- ) ;
87+ it ( 'omits missing Variables from objects' , ( ) => {
88+ const ast = parseValue ( '{ foo: 1, bar: $var }' ) ;
89+ const vars = testVariables ( '($wrongVar: Int)' , { var : 123 } ) ;
90+ expect ( replaceVariables ( ast , vars ) ) . to . deep . equal (
91+ parseValue ( '{ foo: 1 }' ) ,
92+ ) ;
93+ } ) ;
8194 } ) ;
8295
8396 describe ( 'Fragment Variables' , ( ) => {
0 commit comments