-
-
Notifications
You must be signed in to change notification settings - Fork 393
/
limits.test.js
73 lines (57 loc) · 2.01 KB
/
limits.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import * as Factory from '../lib/factory.js'
import * as Collaboration from '../lib/Collaboration.js'
chai.use(chaiAsPromised)
const expect = chai.expect
describe('shared vault limits', function () {
this.timeout(Factory.TwentySecondTimeout)
let context
beforeEach(async function () {
localStorage.clear()
context = await Factory.createVaultsContextWithRealCrypto()
await context.launch()
await context.register()
})
afterEach(async function () {
await context.deinit()
localStorage.clear()
sinon.restore()
})
describe('free users', () => {
it('should not allow creating vaults over the limit', async () => {
const firstSharedVault = await Collaboration.createSharedVault(context)
expect(firstSharedVault).to.not.be.null
let caughtError = null
try {
await Collaboration.createSharedVault(context)
} catch (error) {
caughtError = error
}
expect(caughtError.message).to.equal('Failed to create shared vault: You have reached the limit of shared vaults for your account.')
})
})
describe('plus users', () => {
it('should not allow creating vaults over the limit', async () => {
context.activatePaidSubscriptionForUser({ subscriptionPlanName: 'PLUS_PLAN' })
for (let i = 0; i < 3; i++) {
const vault = await Collaboration.createSharedVault(context)
expect(vault).to.not.be.null
}
let caughtError = null
try {
await Collaboration.createSharedVault(context)
} catch (error) {
caughtError = error
}
expect(caughtError.message).to.equal('Failed to create shared vault: You have reached the limit of shared vaults for your account.')
})
})
describe('pro users', () => {
it('should allow creating vaults without limit', async () => {
context.activatePaidSubscriptionForUser()
for (let i = 0; i < 10; i++) {
const vault = await Collaboration.createSharedVault(context)
expect(vault).to.not.be.null
}
})
})
})