Skip to content

Commit f8b29b3

Browse files
committed
add test
1 parent 64840aa commit f8b29b3

2 files changed

Lines changed: 17 additions & 2 deletions

File tree

zerva-core/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
{
22
"name": "@zerva/core",
33
"type": "module",
4-
"version": "0.61.0",
4+
"version": "0.61.1",
55
"description": "🌱 Simple event driven server",
66
"author": {
77
"name": "Dirk Holtwick",

zerva-core/src/serve.spec.ts

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { onInit, onStart, onStop, serve, serveStop, setContext } from './index'
1+
import { emit, getContext, on, onInit, onStart, onStop, serve, serveStop, setContext } from './index'
22

33
describe('serve', () => {
44
it('should pass all phases', async () => {
@@ -51,4 +51,19 @@ describe('serve', () => {
5151
}
5252
`)
5353
})
54+
55+
it('should show a warning if event has been added after emit', async () => {
56+
setContext()
57+
58+
let called = false
59+
60+
await emit('test' as any)
61+
62+
on('test' as any, () => {
63+
called = true
64+
})
65+
66+
expect(called).toBe(false)
67+
expect(getContext().eventNamesEmitted.test).toBe(true)
68+
})
5469
})

0 commit comments

Comments
 (0)