@@ -65,19 +65,32 @@ describe('replaceVariables', () => {
65
65
) ;
66
66
} ) ;
67
67
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
+
68
80
it ( 'replaces missing Variables in lists with null' , ( ) => {
69
81
const ast = parseValue ( '[1, $var]' ) ;
70
82
expect ( replaceVariables ( ast , undefined ) ) . to . deep . equal (
71
83
parseValue ( '[1, null]' ) ,
72
84
) ;
73
85
} ) ;
74
- } ) ;
75
86
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
+ } ) ;
81
94
} ) ;
82
95
83
96
describe ( 'Fragment Variables' , ( ) => {
0 commit comments