Skip to content

Commit

Permalink
Update mock.js
Browse files Browse the repository at this point in the history
Adds contains to objectSotreNames https://html.spec.whatwg.org/multipage/common-dom-interfaces.html#the-domstringlist-interface

The shelving indexedDBmock just returns an array, but indexOf isn't valid in the browser, so there isn't anything I can do.
  • Loading branch information
Matt Gaunt authored Dec 16, 2017
1 parent 27a014e commit 73ac26d
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/mock.js
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ const storage = {}; // Root storage.
Object.defineProperty(this, 'version', { value: version, enumerable: true });
Object.defineProperty(this, 'objectStoreNames', {
enumerable: true,
get() { const names = Object.keys(data); names.sort(); return names; },
get() {
const names = Object.keys(data);
names.sort();
// Fake contains from DOMStringList
names.contains = (valueTest) => names.indexOf(valueTest) !== -1;
return names;
},
set() { throw new Error('IDBDatabase: _data is read only'); }
});
Object.defineProperty(this, '_data', {
Expand Down Expand Up @@ -1563,4 +1569,4 @@ module.exports.validKey = validKey;
module.exports.validKeyRange = validKeyRange;
module.exports.keyInRange = keyInRange;
module.exports.clone = clone;
module.exports.reset = reset;
module.exports.reset = reset;

0 comments on commit 73ac26d

Please sign in to comment.