@@ -688,6 +688,72 @@ describe('Named expressions - evaluation', () => {
688
688
expect ( engine . getNamedExpressionValue ( 'myName' ) ) . toEqual ( 30 )
689
689
} )
690
690
691
+ it ( 'user original' , ( ) => {
692
+ const options = {
693
+ licenseKey : 'gpl-v3' ,
694
+ evaluateNullToZero : true ,
695
+ }
696
+
697
+ const hfInstance = HyperFormula . buildFromSheets (
698
+ {
699
+ Sheet1 : [ [ 1 , 2 , '=SUM(test)' ] ] ,
700
+ } ,
701
+ options ,
702
+ [
703
+ {
704
+ name : 'test' ,
705
+ expression : '=Sheet1!$A$1:$B$1' ,
706
+ } ,
707
+ ]
708
+ )
709
+
710
+
711
+ hfInstance . setCellContents ( { sheet : 0 , col : 0 , row : 0 } , 4 )
712
+ expect ( hfInstance . getCellValue ( adr ( 'C1' ) ) ) . toEqual ( 6 )
713
+
714
+ hfInstance . setCellContents ( { sheet : 0 , col : 0 , row : 0 } , 14 )
715
+ expect ( hfInstance . getCellValue ( adr ( 'C1' ) ) ) . toEqual ( 16 )
716
+ } )
717
+
718
+ it ( 'user min' , ( ) => {
719
+ const hfInstance = HyperFormula . buildFromSheets (
720
+ { Sheet1 : [ [ 1 ] ] } ,
721
+ { } ,
722
+ [ { name : 'test' , expression : '=Sheet1!$A$1' } ]
723
+ )
724
+
725
+ expect ( hfInstance . getNamedExpressionValue ( 'test' ) ) . toEqual ( 1 )
726
+
727
+ hfInstance . setCellContents ( { sheet : 0 , col : 0 , row : 0 } , 2 )
728
+ expect ( hfInstance . getNamedExpressionValue ( 'test' ) ) . toEqual ( 2 )
729
+
730
+ hfInstance . setCellContents ( { sheet : 0 , col : 0 , row : 0 } , 3 )
731
+ expect ( hfInstance . getNamedExpressionValue ( 'test' ) ) . toEqual ( 3 )
732
+
733
+ hfInstance . setCellContents ( { sheet : 0 , col : 0 , row : 0 } , 4 )
734
+ expect ( hfInstance . getNamedExpressionValue ( 'test' ) ) . toEqual ( 4 )
735
+ } )
736
+
737
+ it ( 'user addNamedExpression' , ( ) => {
738
+ const hfInstance = HyperFormula . buildFromSheets (
739
+ { Sheet1 : [ [ 1 ] ] } ,
740
+ { }
741
+ )
742
+
743
+ hfInstance . addNamedExpression ( 'test' , '=Sheet1!$A$1' )
744
+
745
+ expect ( hfInstance . getNamedExpressionValue ( 'test' ) ) . toEqual ( 1 )
746
+
747
+ hfInstance . setCellContents ( { sheet : 0 , col : 0 , row : 0 } , 2 )
748
+ expect ( hfInstance . getNamedExpressionValue ( 'test' ) ) . toEqual ( 2 )
749
+
750
+ hfInstance . setCellContents ( { sheet : 0 , col : 0 , row : 0 } , 3 )
751
+ expect ( hfInstance . getNamedExpressionValue ( 'test' ) ) . toEqual ( 3 )
752
+
753
+ hfInstance . setCellContents ( { sheet : 0 , col : 0 , row : 0 } , 4 )
754
+ expect ( hfInstance . getNamedExpressionValue ( 'test' ) ) . toEqual ( 4 )
755
+ } )
756
+
691
757
it ( 'should reevaluate volatile function in named expression' , ( ) => {
692
758
const engine = HyperFormula . buildFromArray ( [ ] )
693
759
0 commit comments