Test for reliably auth info across reforges

This commit is contained in:
Daniel Lugo 2021-09-23 16:35:30 -04:00
parent 596c7c8281
commit 9d342a460c

View file

@ -434,14 +434,18 @@ describe('gun smith', () => {
const alias = words()
const pass = words()
jest.setTimeout(20000)
it('provides an user node with create(), auth() and leave()', async done => {
expect.assertions(6)
expect.assertions(7)
await whenReady()
const ack = await new Promise(res => user.create(alias, pass, res))
expect(ack.err).toBeUndefined()
const { pub } = ack
// eslint-disable-next-line jest/no-truthy-falsy
expect(pub).toBeTruthy()
expect(user.is?.pub).toEqual(pub)
user.leave()
@ -458,6 +462,28 @@ describe('gun smith', () => {
done()
release()
})
it('reliably provides authentication information across re-forges', async done => {
expect.assertions(3)
await whenReady()
/** @type {GunT.AuthAck} */
const authAck = await new Promise(res =>
user.auth(alias, pass, ack => res(ack))
)
const pub = authAck.sea?.pub
// eslint-disable-next-line jest/no-truthy-falsy
expect(pub).toBeTruthy()
Gun._reforge()
expect(user.is?.pub).toEqual(pub)
await Gun._isReady()
expect(user.is?.pub).toEqual(pub)
user.leave()
done()
release()
})
})
it('provides thenables for values', async done => {