Skip to content

Commit 847aac2

Browse files
committed
Bump dev dependencies and remove sinon
Category: none
1 parent a069162 commit 847aac2

File tree

3 files changed

+54
-31
lines changed

3 files changed

+54
-31
lines changed

package.json

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,20 +33,19 @@
3333
"module-error": "^1.0.1"
3434
},
3535
"devDependencies": {
36-
"@types/node": "^20.11.8",
37-
"@voxpelli/tsconfig": "^10.0.0",
36+
"@types/node": "^22.7.7",
37+
"@voxpelli/tsconfig": "^15.0.0",
3838
"airtap": "^4.0.4",
3939
"airtap-electron": "^1.0.0",
4040
"airtap-playwright": "^1.0.1",
41-
"electron": "^28.2.0",
42-
"hallmark": "^4.0.0",
41+
"electron": "^30.5.1",
42+
"hallmark": "^5.0.1",
4343
"nyc": "^15.1.0",
44-
"sinon": "^17.0.1",
45-
"standard": "^17.1.0",
46-
"tap-arc": "^1.2.2",
47-
"tape": "^5.7.4",
44+
"standard": "^17.1.2",
45+
"tap-arc": "^1.3.2",
46+
"tape": "^5.9.0",
4847
"ts-standard": "^12.0.2",
49-
"typescript": "^5.3.3"
48+
"typescript": "^5.6.3"
5049
},
5150
"repository": {
5251
"type": "git",

test/self.js

Lines changed: 21 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,10 @@
11
'use strict'
22

33
const test = require('tape')
4-
const sinon = require('sinon')
54
const isBuffer = require('is-buffer')
65
const { Buffer } = require('buffer')
76
const { AbstractLevel, AbstractChainedBatch } = require('..')
8-
const { MinimalLevel } = require('./util')
7+
const { MinimalLevel, createSpy } = require('./util')
98
const getRangeOptions = require('../lib/range-options')
109

1110
const testCommon = require('./common')({
@@ -55,7 +54,7 @@ test('manifest is required', function (t) {
5554
})
5655

5756
test('test open() extensibility when new', async function (t) {
58-
const spy = sinon.spy(async function () {})
57+
const spy = createSpy(async function () {})
5958
const expectedOptions = { createIfMissing: true, errorIfExists: false }
6059
const Test = implement(AbstractLevel, { _open: spy })
6160
const test = new Test({ encodings: { utf8: true } })
@@ -81,7 +80,7 @@ test('test open() extensibility when new', async function (t) {
8180
test('test open() extensibility when open', function (t) {
8281
t.plan(2)
8382

84-
const spy = sinon.spy(async function () {})
83+
const spy = createSpy(async function () {})
8584
const Test = implement(AbstractLevel, { _open: spy })
8685
const test = new Test({ encodings: { utf8: true } })
8786

@@ -97,7 +96,7 @@ test('test open() extensibility when open', function (t) {
9796
test('test opening explicitly gives a chance to capture an error', async function (t) {
9897
t.plan(3)
9998

100-
const spy = sinon.spy(async function (options) { throw new Error('_open error') })
99+
const spy = createSpy(async function (options) { throw new Error('_open error') })
101100
const Test = implement(AbstractLevel, { _open: spy })
102101
const test = new Test({ encodings: { utf8: true } })
103102

@@ -111,7 +110,7 @@ test('test opening explicitly gives a chance to capture an error', async functio
111110
})
112111

113112
test('test constructor options are forwarded to open()', async function (t) {
114-
const spy = sinon.spy(async function (options) { })
113+
const spy = createSpy(async function (options) { })
115114
const Test = implement(AbstractLevel, { _open: spy })
116115
const test = new Test({ encodings: { utf8: true } }, {
117116
passive: true,
@@ -132,7 +131,7 @@ test('test constructor options are forwarded to open()', async function (t) {
132131
})
133132

134133
test('test close() extensibility when open', async function (t) {
135-
const spy = sinon.spy(async function () {})
134+
const spy = createSpy(async function () {})
136135
const Test = implement(AbstractLevel, { _close: spy })
137136
const test = new Test({ encodings: { utf8: true } })
138137

@@ -145,7 +144,7 @@ test('test close() extensibility when open', async function (t) {
145144
})
146145

147146
test('test close() extensibility when new', async function (t) {
148-
const spy = sinon.spy(async function () {})
147+
const spy = createSpy(async function () {})
149148
const Test = implement(AbstractLevel, { _close: spy })
150149
const test = new Test({ encodings: { utf8: true } })
151150

@@ -288,7 +287,7 @@ test('open() error is combined with resource error', async function (t) {
288287
})
289288

290289
test('test get() extensibility', async function (t) {
291-
const spy = sinon.spy(async function () {})
290+
const spy = createSpy(async function () {})
292291
const expectedOptions = { keyEncoding: 'utf8', valueEncoding: 'utf8' }
293292
const expectedKey = 'a key'
294293
const Test = implement(AbstractLevel, { _get: spy })
@@ -314,7 +313,7 @@ test('test get() extensibility', async function (t) {
314313
})
315314

316315
test('test getMany() extensibility', async function (t) {
317-
const spy = sinon.spy(async () => ['x'])
316+
const spy = createSpy(async () => ['x'])
318317
const expectedOptions = { keyEncoding: 'utf8', valueEncoding: 'utf8' }
319318
const expectedKey = 'a key'
320319
const Test = implement(AbstractLevel, { _getMany: spy })
@@ -340,7 +339,7 @@ test('test getMany() extensibility', async function (t) {
340339
})
341340

342341
test('test del() extensibility', async function (t) {
343-
const spy = sinon.spy(async function () {})
342+
const spy = createSpy(async function () {})
344343
const expectedOptions = { options: 1, keyEncoding: 'utf8' }
345344
const expectedKey = 'a key'
346345
const Test = implement(AbstractLevel, { _del: spy })
@@ -365,7 +364,7 @@ test('test del() extensibility', async function (t) {
365364
})
366365

367366
test('test put() extensibility', async function (t) {
368-
const spy = sinon.spy(async function () {})
367+
const spy = createSpy(async function () {})
369368
const expectedOptions = { options: 1, keyEncoding: 'utf8', valueEncoding: 'utf8' }
370369
const expectedKey = 'a key'
371370
const expectedValue = 'a value'
@@ -393,7 +392,7 @@ test('test put() extensibility', async function (t) {
393392
})
394393

395394
test('batch([]) extensibility', async function (t) {
396-
const spy = sinon.spy(async function () {})
395+
const spy = createSpy(async function () {})
397396
const expectedOptions = { options: 1 }
398397
const expectedArray = [
399398
{ type: 'put', key: '1', value: '1', keyEncoding: 'utf8', valueEncoding: 'utf8' },
@@ -431,7 +430,7 @@ test('batch([]) extensibility', async function (t) {
431430
test('batch([]) with empty array is a noop', function (t) {
432431
t.plan(1)
433432

434-
const spy = sinon.spy()
433+
const spy = createSpy()
435434
const Test = implement(AbstractLevel, { _batch: spy })
436435
const test = new Test({ encodings: { utf8: true } })
437436

@@ -443,7 +442,7 @@ test('batch([]) with empty array is a noop', function (t) {
443442
})
444443

445444
test('test chained batch() extensibility', async function (t) {
446-
const spy = sinon.spy(async function () {})
445+
const spy = createSpy(async function () {})
447446
const expectedOptions = { options: 1 }
448447
const Test = implement(AbstractLevel, { _batch: spy })
449448
const test = new Test({ encodings: { utf8: true } })
@@ -473,7 +472,7 @@ test('test chained batch() extensibility', async function (t) {
473472
test('test chained batch() with no operations is a noop', function (t) {
474473
t.plan(1)
475474

476-
const spy = sinon.spy(async function () {})
475+
const spy = createSpy(async function () {})
477476
const Test = implement(AbstractLevel, { _batch: spy })
478477
const test = new Test({ encodings: { utf8: true } })
479478

@@ -485,7 +484,7 @@ test('test chained batch() with no operations is a noop', function (t) {
485484
})
486485

487486
test('test chained batch() (custom _chainedBatch) extensibility', async function (t) {
488-
const spy = sinon.spy()
487+
const spy = createSpy()
489488
const Test = implement(AbstractLevel, { _chainedBatch: spy })
490489
const test = new Test({ encodings: { utf8: true } })
491490

@@ -583,7 +582,7 @@ test('test AbstractChainedBatch#write() extensibility with options', async funct
583582
test('test AbstractChainedBatch#put() extensibility', function (t) {
584583
t.plan(8)
585584

586-
const spy = sinon.spy()
585+
const spy = createSpy()
587586
const expectedKey = 'key'
588587
const expectedValue = 'value'
589588
const Test = implement(AbstractChainedBatch, { _put: spy })
@@ -610,7 +609,7 @@ test('test AbstractChainedBatch#put() extensibility', function (t) {
610609
test('test AbstractChainedBatch#del() extensibility', function (t) {
611610
t.plan(6)
612611

613-
const spy = sinon.spy()
612+
const spy = createSpy()
614613
const expectedKey = 'key'
615614
const Test = implement(AbstractChainedBatch, { _del: spy })
616615
const db = testCommon.factory()
@@ -634,7 +633,7 @@ test('test AbstractChainedBatch#del() extensibility', function (t) {
634633
test('test AbstractChainedBatch#clear() extensibility', function (t) {
635634
t.plan(4)
636635

637-
const spy = sinon.spy()
636+
const spy = createSpy()
638637
const Test = implement(AbstractChainedBatch, { _clear: spy })
639638
const db = testCommon.factory()
640639

@@ -652,7 +651,7 @@ test('test AbstractChainedBatch#clear() extensibility', function (t) {
652651
test('test clear() extensibility', async function (t) {
653652
t.plan((7 * 4) - 3)
654653

655-
const spy = sinon.spy()
654+
const spy = createSpy()
656655
const Test = implement(AbstractLevel, { _clear: spy })
657656
const db = new Test({ encodings: { utf8: true } })
658657

@@ -685,7 +684,7 @@ test('test clear() extensibility', async function (t) {
685684
test.skip('test serialization extensibility (batch array is not mutated)', function (t) {
686685
t.plan(7)
687686

688-
const spy = sinon.spy()
687+
const spy = createSpy()
689688
const Test = implement(AbstractLevel, {
690689
_batch: spy,
691690
_serializeKey: function (key) {

test/util.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
const { AbstractLevel, AbstractChainedBatch } = require('..')
44
const { AbstractIterator, AbstractKeyIterator, AbstractValueIterator } = require('..')
5+
const noop = function () {}
56

67
exports.illegalKeys = [
78
{ name: 'null key', key: null },
@@ -53,6 +54,30 @@ exports.nullishEncoding = {
5354
}
5455
}
5556

57+
// Replacement for sinon package (which breaks too often, on features we don't use)
58+
exports.createSpy = function (fn = noop) {
59+
let calls = []
60+
61+
const spy = function (...args) {
62+
const returnValue = fn(...args)
63+
calls.push({ thisValue: this, args, returnValue })
64+
spy.callCount++
65+
return returnValue
66+
}
67+
68+
spy.callCount = 0
69+
spy.getCall = function (n) {
70+
return calls[n]
71+
}
72+
73+
spy.resetHistory = function () {
74+
calls = []
75+
spy.callCount = 0
76+
}
77+
78+
return spy
79+
}
80+
5681
const kEntries = Symbol('entries')
5782
const kPosition = Symbol('position')
5883
const kOptions = Symbol('options')

0 commit comments

Comments
 (0)