Skip to content

Commit

Permalink
Merge pull request #26 from martinRenou/allow_zero_in_cell
Browse files Browse the repository at this point in the history
Allow zero value in cells
  • Loading branch information
martinRenou committed Feb 13, 2019
2 parents 73a60af + 7023e91 commit d1c64d3
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions js/src/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,9 @@ let SheetModel = widgets.DOMWidgetModel.extend({
},
_cell_data_to_grid: function(cell, data) {
let value = cell.get('value');
if(!value)
return
if((value === null) || (value === undefined)) {
return;
}
for(let i = cell.get('row_start'); i <= cell.get('row_end'); i++) {
for(let j = cell.get('column_start'); j <= cell.get('column_end'); j++) {
let value = cell.get('value');
Expand Down
5 changes: 5 additions & 0 deletions js/src/test/sheet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,11 @@ describe('sheet', function() {
var data = this.sheet.get('data')
expect(data[1][2].value, 'when cell.value is change').to.equal(999);
})
it('numeric cell with value zero should indeed have value zero', async function() {
await make_cell.apply(this, [{value: 0.00, type:'numeric'}]);
var data = this.sheet.get('data');
expect(data[1][2].value, 'for initial value').to.equal(0);
})
it('multiple cells added', async function() {
var cell1 = await make_cell.apply(this, [{value: 777}, true])
var cell2 = await make_cell.apply(this, [{row_start: 0, row_end:0, value: 555}, true])
Expand Down

0 comments on commit d1c64d3

Please sign in to comment.