Skip to content

Commit

Permalink
Add test
Browse files Browse the repository at this point in the history
  • Loading branch information
papandreou committed Apr 25, 2018
1 parent 40865c9 commit f741004
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 0 deletions.
Binary file added spec/integration/data/formulas.xlsx
Binary file not shown.
53 changes: 53 additions & 0 deletions spec/integration/workbook-xlsx-reader.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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]');
});
});
});
});

0 comments on commit f741004

Please sign in to comment.