Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

Commit

Permalink
Merge pull request #15068 from NejcZdovc/hotfix/#15067-delay
Browse files Browse the repository at this point in the history
Removes delay for referral
  • Loading branch information
bsclifton committed Aug 21, 2018
1 parent ffb14e0 commit 0df0a5f
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 21 deletions.
9 changes: 1 addition & 8 deletions app/browser/api/ledger.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ let promotionTimeoutId
let togglePromotionTimeoutId
let publisherInfoTimeoutId = false
let publisherInfoUpdateIntervalId
let promoRefFetchTimeoutId = false

const statePath = 'ledger-state.json'

Expand Down Expand Up @@ -2278,13 +2277,7 @@ const initialize = (state, paymentsEnabled) => {
}

const schedulePromoRefFetch = () => {
if (promoRefFetchTimeoutId) {
clearTimeout(promoRefFetchTimeoutId)
}

promoRefFetchTimeoutId = setTimeout(() => {
appActions.onPromoRefFetch()
}, random.randomInt({min: 50 * ledgerUtil.milliseconds.second, max: 70 * ledgerUtil.milliseconds.second}))
appActions.onPromoRefFetch()
}

const onRunPromoRefFetch = (state) => {
Expand Down
15 changes: 2 additions & 13 deletions test/unit/app/browser/api/ledgerTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -2711,35 +2711,24 @@ describe('ledger api unit tests', function () {
})

describe('schedulePromoRefFetch', function () {
const fortySeconds = 40000
const seventySeconds = 70000
let fakeClock, onPromoRefFetchSpy
let onPromoRefFetchSpy

before(function () {
fakeClock = sinon.useFakeTimers()
onPromoRefFetchSpy = sinon.spy(appActions, 'onPromoRefFetch')
})

after(function () {
fakeClock.restore()
onPromoRefFetchSpy.restore()
})

afterEach(function () {
onPromoRefFetchSpy.reset()
})

it('dispatches onPromoRefFetch after 50 - 70 seconds', function () {
it('dispatches onPromoRefFetch', function () {
ledgerApi.schedulePromoRefFetch(defaultAppState)
fakeClock.tick(seventySeconds)
assert(onPromoRefFetchSpy.calledOnce)
})

it('does not dispatch onPromoRefFetch after 40 seconds', function () {
ledgerApi.schedulePromoRefFetch(defaultAppState)
fakeClock.tick(fortySeconds)
assert(onPromoRefFetchSpy.notCalled)
})
})

describe('onRunPromoRefFetch', function () {
Expand Down

0 comments on commit 0df0a5f

Please sign in to comment.