From 1e90c9968a7459a1afb1e3e0d38a3799f465444e Mon Sep 17 00:00:00 2001 From: Lars-Magnus Skog Date: Mon, 28 May 2018 15:29:48 +0200 Subject: [PATCH] Remove levelup from destroy tests --- package.json | 2 -- test/custom-test.js | 60 ++++++++++++++++++++++++++------------------- test/index.js | 5 ---- 3 files changed, 35 insertions(+), 32 deletions(-) diff --git a/package.json b/package.json index 9a9fd4e..d8129ba 100644 --- a/package.json +++ b/package.json @@ -28,8 +28,6 @@ "devDependencies": { "airtap": "0.0.7", "buffer": "~5.1.0", - "levelup": "~3.0.0", - "pinkie": "~2.0.4", "standard": "^11.0.1", "tape": "^4.0.0" }, diff --git a/test/custom-test.js b/test/custom-test.js index 59f0257..baf1dd8 100644 --- a/test/custom-test.js +++ b/test/custom-test.js @@ -1,7 +1,5 @@ 'use strict' -var levelup = require('levelup') - module.exports = function (leveljs, test, testCommon) { test('setUp', testCommon.setUp) @@ -165,22 +163,28 @@ module.exports = function (leveljs, test, testCommon) { // NOTE: in chrome (at least) indexeddb gets buggy if you try and destroy a db, // then create it again, then try and destroy it again. these avoid doing that - test('test levelup .destroy', function (t) { + test('test .destroy', function (t) { var location = testCommon.location() - var db = levelup(leveljs(location)) - db.put('key', 'value', function (err) { + var db = leveljs(location) + db.open(function (err) { t.notOk(err, 'no error') - db.get('key', { asBuffer: false }, function (err, value) { + db.put('key', 'value', function (err) { t.notOk(err, 'no error') - t.equal(value, 'value', 'should have value') - db.close(function (err) { + db.get('key', { asBuffer: false }, function (err, value) { t.notOk(err, 'no error') - leveljs.destroy(location, function (err) { + t.equal(value, 'value', 'should have value') + db.close(function (err) { t.notOk(err, 'no error') - var db2 = levelup(leveljs(location)) - db2.get('key', { asBuffer: false }, function (err, value) { - t.ok(err && err.notFound, 'key is not there') - db2.close(t.end.bind(t)) + leveljs.destroy(location, function (err) { + t.notOk(err, 'no error') + var db2 = leveljs(location) + db2.open(function (err) { + t.notOk(err, 'no error') + db2.get('key', { asBuffer: false }, function (err, value) { + t.is(err.message, 'NotFound', 'key is not there') + db2.close(t.end.bind(t)) + }) + }) }) }) }) @@ -188,23 +192,29 @@ module.exports = function (leveljs, test, testCommon) { }) }) - test('test levelup .destroy and custom prefix', function (t) { + test('test .destroy and custom prefix', function (t) { var location = testCommon.location() - var prefix = 'CUSTOM-PREFIX-' - var db = levelup(leveljs(location, { prefix: prefix })) - db.put('key', 'value', function (err) { + var prefix = 'custom-' + var db = leveljs(location, { prefix: prefix }) + db.open(function (err) { t.notOk(err, 'no error') - db.get('key', { asBuffer: false }, function (err, value) { + db.put('key', 'value', function (err) { t.notOk(err, 'no error') - t.equal(value, 'value', 'should have value') - db.close(function (err) { + db.get('key', { asBuffer: false }, function (err, value) { t.notOk(err, 'no error') - leveljs.destroy(location, prefix, function (err) { + t.equal(value, 'value', 'should have value') + db.close(function (err) { t.notOk(err, 'no error') - var db2 = levelup(leveljs(location, { prefix: prefix })) - db2.get('key', { asBuffer: false }, function (err, value) { - t.ok(err && err.notFound, 'key is not there') - db2.close(t.end.bind(t)) + leveljs.destroy(location, prefix, function (err) { + t.notOk(err, 'no error') + var db2 = leveljs(location, { prefix: prefix }) + db2.open(function (err) { + t.notOk(err, 'no error') + db2.get('key', { asBuffer: false }, function (err, value) { + t.is(err.message, 'NotFound', 'key is not there') + db2.close(t.end.bind(t)) + }) + }) }) }) }) diff --git a/test/index.js b/test/index.js index 9aadf2b..145dfd4 100644 --- a/test/index.js +++ b/test/index.js @@ -1,10 +1,5 @@ 'use strict' -// Promise polyfill for IE and others. -if (process.browser && typeof Promise !== 'function') { - global.Promise = require('pinkie') -} - // Load IndexedDBShim // require('./util/idb-shim.js')()