Browse Source

improve test

ameba23 2 years ago
parent
commit
fc125de3bc
2 changed files with 8 additions and 4 deletions
  1. 4
    1
      index.js
  2. 4
    3
      test/index.test.js

+ 4
- 1
index.js View File

@@ -18,7 +18,10 @@ function broadcast (msg, opts = {}) {
18 18
     stream.write(msg)
19 19
   }, interval)
20 20
 
21
-  return () => { clearInterval(destroy) && stream.destroy() }
21
+  return () => {
22
+    clearInterval(destroy)
23
+    stream.end() // destroy() ?
24
+  }
22 25
 }
23 26
 
24 27
 function receive (callback, opts = {}) {

+ 4
- 3
test/index.test.js View File

@@ -9,9 +9,10 @@ describe('basic', (context) => {
9 9
     console.log(destroy)
10 10
     setTimeout(() => {
11 11
       destroy()
12
+      next()
12 13
     }, 2000)
13
-    // receive((msg) => {
14
-    //   console.log(msg)
15
-    // })
14
+    receive((msg) => {
15
+      console.log(msg)
16
+    })
16 17
   })
17 18
 })