All files / react-native-mock/src/mocks ListViewDataSource.js

30% Statements 3/10
0% Branches 0/4
0% Functions 0/3
30% Lines 3/10
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 211x   1x                                 1x  
const DataSource = require('ListViewDataSource');  // eslint-disable-line import/no-unresolved
 
DataSource.prototype.toJSON = function () {
  function ListViewDataSource(dataBlob) {
    this.items = 0;
    // Ensure this doesn't throw.
    try {
      Object.keys(dataBlob).forEach(key => {
        this.items += dataBlob[key] && (
          dataBlob[key].length || dataBlob[key].size || 0
        );
      });
    } catch (e) {
      this.items = 'unknown';
    }
  }
  return new ListViewDataSource(this._dataBlob);
};
 
module.exports = DataSource;