|
|
|
@ -2,14 +2,14 @@ contract('DayLimit', function(accounts) { |
|
|
|
|
|
|
|
|
|
it('should construct with the passed daily limit', async function() { |
|
|
|
|
let initLimit = 10; |
|
|
|
|
let dayLimit = await DayLimitMock.new(initLimit, accounts, 2); |
|
|
|
|
let dayLimit = await DayLimitMock.new(initLimit); |
|
|
|
|
let dailyLimit = await dayLimit.dailyLimit(); |
|
|
|
|
assert.equal(initLimit, dailyLimit); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
it('should be able to spend if daily limit is not reached', async function() { |
|
|
|
|
let limit = 10; |
|
|
|
|
let dayLimit = await DayLimitMock.new(limit, accounts, 1); |
|
|
|
|
let dayLimit = await DayLimitMock.new(limit); |
|
|
|
|
|
|
|
|
|
await dayLimit.attemptSpend(8); |
|
|
|
|
let spentToday = await dayLimit.spentToday(); |
|
|
|
@ -22,7 +22,7 @@ contract('DayLimit', function(accounts) { |
|
|
|
|
|
|
|
|
|
it('should prevent spending if daily limit is reached', async function() { |
|
|
|
|
let limit = 10; |
|
|
|
|
let dayLimit = await DayLimitMock.new(limit, accounts, 1); |
|
|
|
|
let dayLimit = await DayLimitMock.new(limit); |
|
|
|
|
|
|
|
|
|
await dayLimit.attemptSpend(8); |
|
|
|
|
let spentToday = await dayLimit.spentToday(); |
|
|
|
@ -35,7 +35,7 @@ contract('DayLimit', function(accounts) { |
|
|
|
|
|
|
|
|
|
it('should allow spending if daily limit is reached and then set higher', async function() { |
|
|
|
|
let limit = 10; |
|
|
|
|
let dayLimit = await DayLimitMock.new(limit, accounts, 1); |
|
|
|
|
let dayLimit = await DayLimitMock.new(limit); |
|
|
|
|
|
|
|
|
|
await dayLimit.attemptSpend(8); |
|
|
|
|
let spentToday = await dayLimit.spentToday(); |
|
|
|
@ -53,7 +53,7 @@ contract('DayLimit', function(accounts) { |
|
|
|
|
|
|
|
|
|
it('should allow spending if daily limit is reached and then amount spent is reset', async function() { |
|
|
|
|
let limit = 10; |
|
|
|
|
let dayLimit = await DayLimitMock.new(limit, accounts, 1); |
|
|
|
|
let dayLimit = await DayLimitMock.new(limit); |
|
|
|
|
|
|
|
|
|
await dayLimit.attemptSpend(8); |
|
|
|
|
let spentToday = await dayLimit.spentToday(); |
|
|
|
|