-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
40865c9
commit f741004
Showing
2 changed files
with
53 additions
and
0 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -63,4 +63,57 @@ describe('WorkbookReader', function() { | |
}); | ||
}); | ||
}); | ||
|
||
describe('with a spreadsheet that contains formulas', function() { | ||
before(function() { | ||
var testContext = this; | ||
var workbook = new Excel.Workbook(); | ||
return workbook.xlsx.read(fs.createReadStream('./spec/integration/data/formulas.xlsx')) | ||
.then(function() { | ||
testContext.worksheet = workbook.getWorksheet(); | ||
}); | ||
}); | ||
|
||
describe('with a cell that contains a regular formula', function() { | ||
beforeEach(function() { | ||
this.cell = this.worksheet.getCell('A2'); | ||
}); | ||
|
||
it('should be classified as a formula cell', function() { | ||
expect(this.cell.type).to.equal(Excel.ValueType.Formula); | ||
expect(this.cell.isFormula).to.be.true; | ||
}); | ||
|
||
it('should have text corresponding to the evaluated formula result', function() { | ||
expect(this.cell.text).to.equal('[email protected]'); | ||
}); | ||
|
||
it('should have the formula source', function() { | ||
expect(this.cell.model.formula).to.equal('_xlfn.CONCAT("someone","@example.com")'); | ||
}); | ||
}); | ||
|
||
describe('with a cell that contains a hyperlinked formula', function() { | ||
beforeEach(function() { | ||
this.cell = this.worksheet.getCell('A1'); | ||
}); | ||
|
||
it('should be classified as a formula cell', function() { | ||
expect(this.cell.type).to.equal(Excel.ValueType.Hyperlink); | ||
}); | ||
|
||
it('should have text corresponding to the evaluated formula result', function() { | ||
expect(this.cell.value.text).to.equal('[email protected]'); | ||
}); | ||
|
||
it('should have the formula source', function() { | ||
expect(this.cell.model.formula).to.equal('_xlfn.CONCAT("someone","@example.com")'); | ||
}); | ||
|
||
it('should contain the linked url', function() { | ||
expect(this.cell.value.hyperlink).to.equal('mailto:[email protected]'); | ||
expect(this.cell.hyperlink).to.equal('mailto:[email protected]'); | ||
}); | ||
}); | ||
}); | ||
}); |