From 89c206ff032518dd8bb8dae4af24547ddde88f33 Mon Sep 17 00:00:00 2001 From: Daniel Lugo Date: Fri, 17 Sep 2021 17:07:54 -0400 Subject: [PATCH] specialOnce() test foundations --- utils/GunSmith/GunSmith.js | 1 - utils/GunSmith/GunSmith.spec.js | 24 ++++++++++++++++++++++++ 2 files changed, 24 insertions(+), 1 deletion(-) diff --git a/utils/GunSmith/GunSmith.js b/utils/GunSmith/GunSmith.js index 01dc37e1..bc26fdc0 100644 --- a/utils/GunSmith/GunSmith.js +++ b/utils/GunSmith/GunSmith.js @@ -233,7 +233,6 @@ const isReady = () => isReady().then(res) }, 1000) } else { - logger.info('isReady') res() } }) diff --git a/utils/GunSmith/GunSmith.spec.js b/utils/GunSmith/GunSmith.spec.js index cb9d87c4..5a2bf8a8 100644 --- a/utils/GunSmith/GunSmith.spec.js +++ b/utils/GunSmith/GunSmith.spec.js @@ -426,4 +426,28 @@ describe('gun smith', () => { done() 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) + }) })