Skip to content

Commit 8d399fa

Browse files
committed
test: feathers-client mocks call cb function
This prevents the milliion “uncaught exception” errors that happen 5 seconds after the tests finish.
1 parent 613b16a commit 8d399fa

File tree

1 file changed

+20
-10
lines changed

1 file changed

+20
-10
lines changed

test/fixtures/feathers-client.js

Lines changed: 20 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,40 +11,50 @@ const baseUrl = 'http://localhost:3030'
1111

1212
// These are fixtures used in the service-modulet.test.js under socket events.
1313
let id = 0
14-
mockServer.on('things::create', function (data) {
14+
mockServer.on('things::create', function (data, params, cb) {
1515
data.id = id
1616
id++
1717
mockServer.emit('things created', data)
18+
cb(null, data)
1819
})
19-
mockServer.on('things::patch', function (id, data) {
20+
mockServer.on('things::patch', function (id, data, params, cb) {
2021
Object.assign(data, { id, test: true })
2122
mockServer.emit('things patched', data)
23+
cb(null, data)
2224
})
23-
mockServer.on('things::update', function (id, data) {
25+
mockServer.on('things::update', function (id, data, params, cb) {
2426
Object.assign(data, { id, test: true })
2527
mockServer.emit('things updated', data)
28+
cb(null, data)
2629
})
27-
mockServer.on('things::remove', function (id) {
28-
mockServer.emit('things removed', { id, test: true })
30+
mockServer.on('things::remove', function (id, obj, cb) {
31+
const response = { id, test: true }
32+
mockServer.emit('things removed', response)
33+
cb(null, response)
2934
})
3035

3136
let idDebounce = 0
3237

33-
mockServer.on('things-debounced::create', function (data) {
38+
mockServer.on('things-debounced::create', function (data, obj, cb) {
3439
data.id = idDebounce
3540
idDebounce++
3641
mockServer.emit('things-debounced created', data)
42+
cb(null, data)
3743
})
38-
mockServer.on('things-debounced::patch', function (id, data) {
44+
mockServer.on('things-debounced::patch', function (id, data, params, cb) {
3945
Object.assign(data, { id, test: true })
4046
mockServer.emit('things-debounced patched', data)
47+
cb(null, data)
4148
})
42-
mockServer.on('things-debounced::update', function (id, data) {
49+
mockServer.on('things-debounced::update', function (id, data, params, cb) {
4350
Object.assign(data, { id, test: true })
4451
mockServer.emit('things-debounced updated', data)
52+
cb(null, data)
4553
})
46-
mockServer.on('things-debounced::remove', function (id) {
47-
mockServer.emit('things-debounced removed', { id, test: true })
54+
mockServer.on('things-debounced::remove', function (id, params, cb) {
55+
const response = { id, test: true }
56+
mockServer.emit('things-debounced removed', response)
57+
cb(null, response)
4858
})
4959

5060
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type

0 commit comments

Comments
 (0)