Skip to content
This repository has been archived by the owner on Dec 2, 2024. It is now read-only.

Test default and custom prefix #124

Merged
merged 1 commit into from
May 27, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions test/custom-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,50 @@ var levelup = require('levelup')
module.exports = function (leveljs, test, testCommon) {
test('setUp', testCommon.setUp)

test('default prefix', function (t) {
var location = testCommon.location()
var db = leveljs(location)

t.is(db.location, location, 'instance has location property')
t.is(db.prefix, 'level-js-', 'instance has prefix property')

db.open(function (err) {
t.notOk(err, 'no open error')

var idb = db.db
var databaseName = idb.name
var storeNames = idb.objectStoreNames

t.is(databaseName, 'level-js-' + location, 'database name is prefixed')
t.is(storeNames.length, 1, 'created 1 object store')
t.is(storeNames.item(0), location, 'object store name equals location')

db.close(t.end.bind(t))
})
})

test('custom prefix', function (t) {
var location = testCommon.location()
var db = leveljs(location, { prefix: 'custom-' })

t.is(db.location, location, 'instance has location property')
t.is(db.prefix, 'custom-', 'instance has prefix property')

db.open(function (err) {
t.notOk(err, 'no open error')

var idb = db.db
var databaseName = idb.name
var storeNames = idb.objectStoreNames

t.is(databaseName, 'custom-' + location, 'database name is prefixed')
t.is(storeNames.length, 1, 'created 1 object store')
t.is(storeNames.item(0), location, 'object store name equals location')

db.close(t.end.bind(t))
})
})

test('buffer value', function (t) {
var level = leveljs(testCommon.location())
level.open(function (err) {
Expand Down