Authentication section in tests
This commit is contained in:
parent
06d20f9c16
commit
84ff20995b
1 changed files with 21 additions and 19 deletions
|
|
@ -429,32 +429,34 @@ describe('gun smith', () => {
|
||||||
// }, 800)
|
// }, 800)
|
||||||
// })
|
// })
|
||||||
|
|
||||||
it('provides an user node with create(), auth() and leave()', async done => {
|
describe('authentication', () => {
|
||||||
expect.assertions(6)
|
|
||||||
await whenReady()
|
|
||||||
|
|
||||||
const user = instance.user()
|
const user = instance.user()
|
||||||
const alias = words()
|
const alias = words()
|
||||||
const pass = words()
|
const pass = words()
|
||||||
|
|
||||||
const ack = await new Promise(res => user.create(alias, pass, res))
|
it('provides an user node with create(), auth() and leave()', async done => {
|
||||||
expect(ack.err).toBeUndefined()
|
expect.assertions(6)
|
||||||
|
await whenReady()
|
||||||
|
|
||||||
const { pub } = ack
|
const ack = await new Promise(res => user.create(alias, pass, res))
|
||||||
expect(user.is?.pub).toEqual(pub)
|
expect(ack.err).toBeUndefined()
|
||||||
|
|
||||||
user.leave()
|
const { pub } = ack
|
||||||
expect(user.is).toBeUndefined()
|
expect(user.is?.pub).toEqual(pub)
|
||||||
|
|
||||||
const authAck = await new Promise(res =>
|
user.leave()
|
||||||
user.auth(alias, pass, ack => res(ack))
|
expect(user.is).toBeUndefined()
|
||||||
)
|
|
||||||
expect(authAck.err).toBeUndefined()
|
const authAck = await new Promise(res =>
|
||||||
expect(authAck.sea.pub).toEqual(pub)
|
user.auth(alias, pass, ack => res(ack))
|
||||||
expect(user.is?.pub).toEqual(pub)
|
)
|
||||||
user.leave()
|
expect(authAck.err).toBeUndefined()
|
||||||
done()
|
expect(authAck.sea.pub).toEqual(pub)
|
||||||
release()
|
expect(user.is?.pub).toEqual(pub)
|
||||||
|
user.leave()
|
||||||
|
done()
|
||||||
|
release()
|
||||||
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
it('provides thenables for values', async done => {
|
it('provides thenables for values', async done => {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue