Better auth test
This commit is contained in:
parent
e95b4154da
commit
db6bb1becb
1 changed files with 11 additions and 8 deletions
|
|
@ -133,12 +133,12 @@ describe('constructor', () => {
|
||||||
b: 1,
|
b: 1,
|
||||||
}
|
}
|
||||||
const c = {...a,...b}
|
const c = {...a,...b}
|
||||||
|
|
||||||
const node = instance.get('foo').get('bar')
|
const node = instance.get('foo').get('bar')
|
||||||
|
|
||||||
node.put(a)
|
node.put(a)
|
||||||
node.put(b)
|
node.put(b)
|
||||||
|
|
||||||
|
|
||||||
node
|
node
|
||||||
.once(data => {
|
.once(data => {
|
||||||
|
|
@ -194,7 +194,7 @@ describe('constructor', () => {
|
||||||
|
|
||||||
it('maps over a primitive set', (done) => {
|
it('maps over a primitive set', (done) => {
|
||||||
expect.assertions(100)
|
expect.assertions(100)
|
||||||
|
|
||||||
const node = instance.get(words()).get(words())
|
const node = instance.get(words()).get(words())
|
||||||
|
|
||||||
const items = words({ exactly: 50 })
|
const items = words({ exactly: 50 })
|
||||||
|
|
@ -202,7 +202,7 @@ describe('constructor', () => {
|
||||||
const ids = items.map(i => node.set(i)._.get)
|
const ids = items.map(i => node.set(i)._.get)
|
||||||
|
|
||||||
let checked = 0
|
let checked = 0
|
||||||
|
|
||||||
node.map().on((data, id) => {
|
node.map().on((data, id) => {
|
||||||
expect(items).toContain(data)
|
expect(items).toContain(data)
|
||||||
expect(ids).toContain(id)
|
expect(ids).toContain(id)
|
||||||
|
|
@ -215,7 +215,7 @@ describe('constructor', () => {
|
||||||
|
|
||||||
it('maps over an object set', (done) => {
|
it('maps over an object set', (done) => {
|
||||||
expect.assertions(100)
|
expect.assertions(100)
|
||||||
|
|
||||||
const node = instance.get(words()).get(words())
|
const node = instance.get(words()).get(words())
|
||||||
|
|
||||||
const items = words({ exactly: 50 }).map(w => ({
|
const items = words({ exactly: 50 }).map(w => ({
|
||||||
|
|
@ -225,7 +225,7 @@ describe('constructor', () => {
|
||||||
const ids = items.map(i => node.set(i)._.get)
|
const ids = items.map(i => node.set(i)._.get)
|
||||||
|
|
||||||
let checked = 0
|
let checked = 0
|
||||||
|
|
||||||
node.map().on((data, id) => {
|
node.map().on((data, id) => {
|
||||||
expect(items).toContainEqual(removeBuiltInGunProps(data))
|
expect(items).toContainEqual(removeBuiltInGunProps(data))
|
||||||
expect(ids).toContain(id)
|
expect(ids).toContain(id)
|
||||||
|
|
@ -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()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue