This repository has been archived by the owner on Dec 1, 2024. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 52
/
Copy pathcommon.js
57 lines (45 loc) · 1.52 KB
/
common.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
'use strict'
function testCommon (options) {
const factory = options.factory
const test = options.test
if (typeof factory !== 'function') {
throw new TypeError('factory must be a function')
}
if (typeof test !== 'function') {
throw new TypeError('test must be a function')
}
if (options.legacyRange != null) {
throw new Error('The legacyRange option has been removed')
}
return {
test: test,
factory: factory,
// TODO (next major): remove
setUp: options.setUp || noopTest(),
tearDown: options.tearDown || noopTest(),
// TODO (next major): use db.supports instead
bufferKeys: options.bufferKeys !== false,
createIfMissing: options.createIfMissing !== false,
errorIfExists: options.errorIfExists !== false,
snapshots: options.snapshots !== false,
seek: options.seek !== false,
clear: !!options.clear,
getMany: !!options.getMany,
// Support running test suite on a levelup db. All options below this line
// are undocumented and should not be used by abstract-leveldown db's (yet).
promises: !!options.promises,
status: options.status !== false,
serialize: options.serialize !== false,
// If true, the test suite assumes a default encoding of utf8 (like levelup)
// and that operations return strings rather than buffers by default.
encodings: !!options.encodings,
deferredOpen: !!options.deferredOpen,
streams: !!options.streams
}
}
function noopTest () {
return function (t) {
t.end()
}
}
module.exports = testCommon