From 73ac26da1b432641bcc03128d37b88a427f8b4ce Mon Sep 17 00:00:00 2001 From: Matt Gaunt Date: Fri, 15 Dec 2017 16:58:03 -0800 Subject: [PATCH] Update mock.js 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. --- lib/mock.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/mock.js b/lib/mock.js index d1b3195..1d77586 100644 --- a/lib/mock.js +++ b/lib/mock.js @@ -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', { @@ -1563,4 +1569,4 @@ module.exports.validKey = validKey; module.exports.validKeyRange = validKeyRange; module.exports.keyInRange = keyInRange; module.exports.clone = clone; -module.exports.reset = reset; \ No newline at end of file +module.exports.reset = reset;