Skip to content

Commit

Permalink
Merge pull request #1237 from brave/exclude-60
Browse files Browse the repository at this point in the history
Fixes exclude in ac table
  • Loading branch information
ryanml authored Jan 7, 2019
2 parents 3a40def + 69cff90 commit 189ba5a
Show file tree
Hide file tree
Showing 2 changed files with 51 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,10 @@ const publishersReducer: Reducer<Rewards.State | undefined> = (state: Rewards.St
break
}

if (!state.excluded) {
state.excluded = []
}

if (!state.excluded.includes(publisherKey)) {
chrome.send('brave_rewards.excludePublisher', [publisherKey])
state.excluded.push(publisherKey)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,4 +123,51 @@ describe('publishers reducer', () => {
})
})
})

describe('ON_EXCLUDE_PUBLISHER', () => {
it('exclude is not defined in the state', () => {
let result = reducers({
rewardsData: { enabledMain: true }
}, {
type: types.ON_EXCLUDE_PUBLISHER,
payload: {
publisherKey: 'clifton.io'
}
})

const expectedState: Rewards.State = {
enabledMain: true,
excluded: [
'clifton.io'
]
}

expect(result).toEqual({
rewardsData: expectedState
})
})

it('exclude already has some data', () => {
let result = reducers({
rewardsData: { ...defaultState, excluded: ['clifton.io'] }
}, {
type: types.ON_EXCLUDE_PUBLISHER,
payload: {
publisherKey: 'brave.com'
}
})

const expectedState: Rewards.State = {
...defaultState,
excluded: [
'clifton.io',
'brave.com'
]
}

expect(result).toEqual({
rewardsData: expectedState
})
})
})
})

0 comments on commit 189ba5a

Please sign in to comment.