MCPcopy
hub / github.com/localForage/localForage / expectStoreToNotExistAsync

Function expectStoreToNotExistAsync

test/test.api.js:1873–1936  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

1871 });
1872
1873 function expectStoreToNotExistAsync(options) {
1874 return new Promise(function(resolve, reject) {
1875 if (driverName === localforage.INDEXEDDB) {
1876 var req = indexedDB.open(options.name);
1877 req.onsuccess = function() {
1878 var db = req.result;
1879 if (!db) {
1880 reject();
1881 return;
1882 }
1883 expect(
1884 db.objectStoreNames.contains(options.storeName)
1885 ).to.be(false);
1886 db.close();
1887 resolve();
1888 };
1889 req.onerror = req.onblocked = reject;
1890 } else if (driverName === localforage.WEBSQL) {
1891 var db = openDatabase(options.name, '', '', 0);
1892 db.transaction(function(t) {
1893 t.executeSql(
1894 "SELECT name FROM sqlite_master WHERE type='table' AND name = ?",
1895 [options.storeName],
1896 function(t, results) {
1897 expect(results.rows.length).to.be(0);
1898 resolve();
1899 },
1900 reject
1901 );
1902 }, reject);
1903 } else if (driverName === localforage.LOCALSTORAGE) {
1904 var keyPrefix = (function _getKeyPrefix(
1905 options,
1906 defaultConfig
1907 ) {
1908 var keyPrefix = options.name + '/';
1909
1910 if (options.storeName !== defaultConfig.storeName) {
1911 keyPrefix += options.storeName + '/';
1912 }
1913 return keyPrefix;
1914 })(options, {
1915 name: 'localforage',
1916 storeName: 'keyvaluepairs'
1917 });
1918
1919 var foundLocalStorageKey = false;
1920 for (
1921 var i = 0, length = localStorage.length;
1922 i < length;
1923 i++
1924 ) {
1925 if (localStorage.key(i).indexOf(keyPrefix) === 0) {
1926 foundLocalStorageKey = true;
1927 break;
1928 }
1929 }
1930 expect(foundLocalStorageKey).to.be(false);

Callers 1

test.api.jsFile · 0.85

Calls 1

keyMethod · 0.80

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…