Better auth test

This commit is contained in:
Daniel Lugo 2021-09-14 11:59:42 -04:00
parent e95b4154da
commit db6bb1becb

View file

@ -318,7 +318,7 @@ describe('constructor', () => {
}) })
it('provides an user node with create(), auth() and leave()', async (done) => { it('provides an user node with create(), auth() and leave()', async (done) => {
expect.assertions(3) expect.assertions(6)
const user = instance.user(); const user = instance.user();
const alias = words() const alias = words()
@ -328,12 +328,15 @@ describe('constructor', () => {
expect(ack.err).toBeUndefined() expect(ack.err).toBeUndefined()
const {pub} = ack; const {pub} = ack;
expect(user.is?.pub).toEqual(pub)
user.leave() user.leave()
expect(user.is).toBeUndefined()
const authAck = await new Promise(res => user.auth(alias, pass, ack => res(ack))) const authAck = await new Promise(res => user.auth(alias, pass, ack => res(ack)))
expect(authAck.err).toBeUndefined() expect(authAck.err).toBeUndefined()
expect(authAck.sea.pub).toEqual(pub) expect(authAck.sea.pub).toEqual(pub)
expect(user.is?.pub).toEqual(pub)
done() done()
}) })
}) })