Skip to content

Commit

Permalink
fix bug when loading empty cell multiple times
Browse files Browse the repository at this point in the history
  • Loading branch information
theoephraim committed Feb 12, 2020
1 parent 786be59 commit be80634
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/GoogleSpreadsheetCell.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ const { columnToLetter } = require('./utils');
const { GoogleSpreadsheetFormulaError } = require('./errors');

class GoogleSpreadsheetCell {
constructor(parentSheet, rowIndex, columnIndex, cellData = {}) {
constructor(parentSheet, rowIndex, columnIndex, cellData) {
this._sheet = parentSheet; // the parent GoogleSpreadsheetWorksheet instance
this._row = rowIndex;
this._column = columnIndex;
Expand All @@ -14,7 +14,8 @@ class GoogleSpreadsheetCell {
return this;
}

_updateRawData(newData) {
// newData can be undefined/null if the cell is totally empty and unformatted
_updateRawData(newData = {}) {
this._rawData = newData;
this._draftData = {}; // stuff to save
this._error = null;
Expand Down
7 changes: 7 additions & 0 deletions test/cells.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ describe('Cell-based operations', () => {
expect(() => { sheet.getCellByA1('A1'); }).toThrow();
});

it('can load a cell multiple times (this was a bug)', async () => {
await sheet.loadCells('J10');
expect(sheet.getCellByA1('J10').value).toBeNull();
await sheet.loadCells('J10');
expect(sheet.getCellByA1('J10').value).toBeNull();
});

describe('invalid filters', () => {
_.each({
'invalid A1 range': 'NOT-A-RANGE',
Expand Down

0 comments on commit be80634

Please sign in to comment.