-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathsubscription.test.js
46 lines (41 loc) · 1.28 KB
/
subscription.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import * as Test from '../test.js'
import * as Account from '../../src/account.js'
import * as Result from '../../src/result.js'
export const SubscriptionClient = Test.withContext({
list: {
'should list subscriptions': async (
assert,
{ client, connection, service, plansStorage, grantAccess, mail }
) => {
const space = await client.createSpace('test')
const email = '[email protected]'
const login = Account.login(client, email)
const message = await mail.take()
assert.deepEqual(message.to, email)
await grantAccess(message)
const account = Result.try(await login)
await account.save()
assert.deepEqual(
await client.capability.subscription.list(account.did()),
{ results: [] }
)
const result = await account.provision(space.did())
assert.ok(result.ok)
assert.deepEqual(
await client.capability.subscription.list(account.did(), {
nonce: 'retry',
}),
{
results: [
{
provider: connection.id.did(),
consumers: [space.did()],
subscription: `${account.did()}:${space.did()}@${connection.id.did()}`,
},
],
}
)
},
},
})
Test.test({ SubscriptionClient })