Skip to content

Commit

Permalink
Fixes stop promotions for notifications
Browse files Browse the repository at this point in the history
Resolves brave#13021

Auditors:

Test Plan:
  • Loading branch information
NejcZdovc authored and ryanml committed Feb 27, 2018
1 parent be5ec04 commit 771ee45
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
3 changes: 2 additions & 1 deletion app/browser/api/ledgerNotifications.js
Original file line number Diff line number Diff line change
Expand Up @@ -364,7 +364,8 @@ const showPromotionNotification = (state) => {
(
getSetting(settings.PAYMENTS_ENABLED) &&
!getSetting(settings.PAYMENTS_NOTIFICATIONS)
)
) ||
!getSetting(settings.PAYMENTS_ALLOW_PROMOTIONS)
) {
return
}
Expand Down
10 changes: 10 additions & 0 deletions test/unit/app/browser/api/ledgerNotificationsTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ describe('ledgerNotifications unit test', function () {
let paymentsNotifications
let paymentsMinVisitTime = 5000
let paymentsContributionAmount = 25
let paymentsAllowPromotions = true

const defaultAppState = Immutable.fromJS({
ledger: {},
Expand Down Expand Up @@ -49,6 +50,8 @@ describe('ledgerNotifications unit test', function () {
return paymentsMinVisitTime
case settings.PAYMENTS_CONTRIBUTION_AMOUNT:
return paymentsContributionAmount
case settings.PAYMENTS_ALLOW_PROMOTIONS:
return paymentsAllowPromotions
}
return false
}
Expand Down Expand Up @@ -591,6 +594,13 @@ describe('ledgerNotifications unit test', function () {
assert(showNotificationSpy.calledOnce)
})

it('promotions are disabled, notification is not shown', function () {
paymentsAllowPromotions = false
ledgerNotificationsApi.showPromotionNotification(state)
assert(showNotificationSpy.notCalled)
paymentsAllowPromotions = true
})

it('notification is shown', function () {
ledgerNotificationsApi.showPromotionNotification(state)
assert(showNotificationSpy.calledOnce)
Expand Down

0 comments on commit 771ee45

Please sign in to comment.