@@ -7,6 +7,8 @@ const {DepParser} = require('../../grammar/dependency/hooks');
77
88const parser = new FormulaParser ( {
99 onCell : ref => {
10+ if ( ref . row === 5 && ref . col === 5 )
11+ return null
1012 return 1 ;
1113 } ,
1214 onRange : ref => {
@@ -107,6 +109,11 @@ describe('Dependency parser', () => {
107109} ) ;
108110
109111describe ( 'Basic parse' , ( ) => {
112+ it ( 'should parse null' , function ( ) {
113+ let actual = parser . parse ( 'E5' , position ) ;
114+ expect ( actual ) . to . deep . eq ( null ) ;
115+ } ) ;
116+
110117 it ( 'should parse whole column' , function ( ) {
111118 let actual = parser . parse ( 'SUM(A:A)' , position ) ;
112119 expect ( actual ) . to . deep . eq ( 6 ) ;
@@ -116,6 +123,7 @@ describe('Basic parse', () => {
116123 let actual = parser . parse ( 'SUM(1:1)' , position ) ;
117124 expect ( actual ) . to . deep . eq ( 1 ) ;
118125 } ) ;
126+
119127} )
120128
121129describe ( 'Parser allows returning array or range' , ( ) => {
@@ -141,6 +149,19 @@ describe('Parser allows returning array or range', () => {
141149 expect ( actual ) . to . eq ( 1 ) ;
142150 } ) ;
143151
152+ it ( 'should return single value' , function ( ) {
153+ let actual = parser . parse ( 'E5' , position , true ) ;
154+ expect ( actual ) . to . eq ( null ) ;
155+ } ) ;
156+ } ) ;
157+
158+ describe ( 'async parse' , ( ) => {
159+ it ( 'should return single value' , async function ( ) {
160+ let actual = await parser . parseAsync ( 'A1' , position , true ) ;
161+ expect ( actual ) . to . eq ( 1 ) ;
162+ actual = await parser . parseAsync ( 'E5' , position , true ) ;
163+ expect ( actual ) . to . eq ( null ) ;
164+ } ) ;
144165} ) ;
145166
146167describe ( 'Custom async function' , ( ) => {
0 commit comments