specialOnce() test foundations
This commit is contained in:
parent
91e2ec08c5
commit
89c206ff03
2 changed files with 24 additions and 1 deletions
|
|
@ -233,7 +233,6 @@ const isReady = () =>
|
||||||
isReady().then(res)
|
isReady().then(res)
|
||||||
}, 1000)
|
}, 1000)
|
||||||
} else {
|
} else {
|
||||||
logger.info('isReady')
|
|
||||||
res()
|
res()
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
|
||||||
|
|
@ -426,4 +426,28 @@ describe('gun smith', () => {
|
||||||
done()
|
done()
|
||||||
release()
|
release()
|
||||||
})
|
})
|
||||||
|
|
||||||
|
// eslint-disable-next-line jest/expect-expect
|
||||||
|
it('provides an special once() that restarts gun until a value is fetched', async done => {
|
||||||
|
expect.assertions(1)
|
||||||
|
await whenReady()
|
||||||
|
jest.setTimeout(100000)
|
||||||
|
|
||||||
|
const a = words()
|
||||||
|
const b = words()
|
||||||
|
const node = instance.get(a).get(b)
|
||||||
|
const value = words()
|
||||||
|
|
||||||
|
node.once(data => {
|
||||||
|
if (data === value) {
|
||||||
|
expect(data).toEqual(value)
|
||||||
|
jest.setTimeout(5000)
|
||||||
|
done()
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
node.put(value)
|
||||||
|
}, 9000)
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue