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

Removes delay for referral #15068

Merged
merged 1 commit into from
Aug 21, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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