1 |
|
2 | const assert = require('assert')
|
3 | const { repeatTake, CLOSED, chan, close, take, put, sleep, go, any } = require('../lib/index')
|
4 |
|
5 | describe('bugs reports', () => {
|
6 |
|
7 | describe('https://github.com/bbarr/medium/issues/3', () => {
|
8 |
|
9 | it('should resolve ch1 put of 123', (cb) => {
|
10 |
|
11 | const channel = chan()
|
12 |
|
13 | go(async () => {
|
14 |
|
15 | const ch1 = chan()
|
16 | const p = sleep(100)
|
17 |
|
18 | put(ch1, 123)
|
19 |
|
20 | const [ v, ch ] = await any(ch1, p)
|
21 |
|
22 | assert.equal(v, 123)
|
23 | }).then(cb)
|
24 | })
|
25 | })
|
26 |
|
27 | describe('https://github.com/bbarr/medium/issues/15', () => {
|
28 |
|
29 | it('should not purge values from buffer after closing channel', async () => {
|
30 |
|
31 | const ch = chan()
|
32 |
|
33 | put(ch, 'foo')
|
34 | close(ch)
|
35 | const result = await take(ch)
|
36 | assert.equal(result, 'foo')
|
37 | })
|
38 | })
|
39 | })
|
40 |
|