@@ -63,4 +63,57 @@ describe('WorkbookReader', function() {
6363 } ) ;
6464 } ) ;
6565 } ) ;
66+
67+ describe ( 'with a spreadsheet that contains formulas' , function ( ) {
68+ before ( function ( ) {
69+ var testContext = this ;
70+ var workbook = new Excel . Workbook ( ) ;
71+ return workbook . xlsx . read ( fs . createReadStream ( './spec/integration/data/formulas.xlsx' ) )
72+ . then ( function ( ) {
73+ testContext . worksheet = workbook . getWorksheet ( ) ;
74+ } ) ;
75+ } ) ;
76+
77+ describe ( 'with a cell that contains a regular formula' , function ( ) {
78+ beforeEach ( function ( ) {
79+ this . cell = this . worksheet . getCell ( 'A2' ) ;
80+ } ) ;
81+
82+ it ( 'should be classified as a formula cell' , function ( ) {
83+ expect ( this . cell . type ) . to . equal ( Excel . ValueType . Formula ) ;
84+ expect ( this . cell . isFormula ) . to . be . true ;
85+ } ) ;
86+
87+ it ( 'should have text corresponding to the evaluated formula result' , function ( ) {
88+ expect ( this . cell . text ) . to . equal ( '[email protected] ' ) ; 89+ } ) ;
90+
91+ it ( 'should have the formula source' , function ( ) {
92+ expect ( this . cell . model . formula ) . to . equal ( '_xlfn.CONCAT("someone","@example.com")' ) ;
93+ } ) ;
94+ } ) ;
95+
96+ describe ( 'with a cell that contains a hyperlinked formula' , function ( ) {
97+ beforeEach ( function ( ) {
98+ this . cell = this . worksheet . getCell ( 'A1' ) ;
99+ } ) ;
100+
101+ it ( 'should be classified as a formula cell' , function ( ) {
102+ expect ( this . cell . type ) . to . equal ( Excel . ValueType . Hyperlink ) ;
103+ } ) ;
104+
105+ it ( 'should have text corresponding to the evaluated formula result' , function ( ) {
106+ expect ( this . cell . value . text ) . to . equal ( '[email protected] ' ) ; 107+ } ) ;
108+
109+ it ( 'should have the formula source' , function ( ) {
110+ expect ( this . cell . model . formula ) . to . equal ( '_xlfn.CONCAT("someone","@example.com")' ) ;
111+ } ) ;
112+
113+ it ( 'should contain the linked url' , function ( ) {
114+ expect ( this . cell . value . hyperlink ) . to . equal ( 'mailto:[email protected] ' ) ; 115+ expect ( this . cell . hyperlink ) . to . equal ( 'mailto:[email protected] ' ) ; 116+ } ) ;
117+ } ) ;
118+ } ) ;
66119} ) ;
0 commit comments