diff --git a/test/app/background/reducers/shieldsPanelReducerTest.ts b/test/app/background/reducers/shieldsPanelReducerTest.ts index 2d73924..6846324 100644 --- a/test/app/background/reducers/shieldsPanelReducerTest.ts +++ b/test/app/background/reducers/shieldsPanelReducerTest.ts @@ -646,8 +646,7 @@ describe('braveShieldsPanelReducer', () => { httpsRedirectedResources: [], javascriptBlockedResources: [ 'https://a.com/index.js', - 'https://b.com/index.js', - 'https://a.com/index.js' + 'https://b.com/index.js' ] } }, @@ -657,6 +656,54 @@ describe('braveShieldsPanelReducer', () => { }) }) + it('increments JS blocking consecutively without duplicates', function () { + this.tabId = 2 + let nextState = shieldsPanelReducer(state, { + type: types.RESOURCE_BLOCKED, + details: { + blockType: 'javascript', + tabId: this.tabId, + subresource: 'https://a.com/index.js' + } + }) + assert.deepEqual( + nextState.tabs[this.tabId].javascriptBlockedResources, + [ 'https://a.com/index.js' ] + ) + + nextState = shieldsPanelReducer(nextState, { + type: types.RESOURCE_BLOCKED, + details: { + blockType: 'javascript', + tabId: this.tabId, + subresource: 'https://b.com/index.js' + } + }) + assert.deepEqual( + nextState.tabs[this.tabId].javascriptBlockedResources, + [ + 'https://a.com/index.js', + 'https://b.com/index.js' + ] + ) + + nextState = shieldsPanelReducer(nextState, { + type: types.RESOURCE_BLOCKED, + details: { + blockType: 'javascript', + tabId: this.tabId, + subresource: 'https://b.com/index.js' + } + }) + assert.deepEqual( + nextState.tabs[this.tabId].javascriptBlockedResources, + [ + 'https://a.com/index.js', + 'https://b.com/index.js' + ] + ) + }) + it('increments for fingerprinting blocked', function () { let nextState = shieldsPanelReducer(state, { type: types.RESOURCE_BLOCKED, @@ -747,7 +794,7 @@ describe('braveShieldsPanelReducer', () => { details: { blockType: 'ads', tabId: 2, - subresource: 'https://test.brave.com' + subresource: 'https://test2.brave.com' } }) assert.deepEqual(nextState, { @@ -774,7 +821,7 @@ describe('braveShieldsPanelReducer', () => { trackersBlockedResources: [], adsBlockedResources: [ 'https://test.brave.com', - 'https://test.brave.com' + 'https://test2.brave.com' ], fingerprintingBlockedResources: [], httpsRedirectedResources: [], @@ -786,6 +833,54 @@ describe('braveShieldsPanelReducer', () => { } }) }) + it('increases same count consecutively without duplicates', function () { + this.tabId = 2 + let nextState = shieldsPanelReducer(state, { + type: types.RESOURCE_BLOCKED, + details: { + blockType: 'ads', + tabId: this.tabId, + subresource: 'https://test.brave.com' + } + }) + assert.deepEqual( + nextState.tabs[this.tabId].adsBlockedResources, + [ 'https://test.brave.com' ] + ) + + nextState = shieldsPanelReducer(nextState, { + type: types.RESOURCE_BLOCKED, + details: { + blockType: 'ads', + tabId: this.tabId, + subresource: 'https://test2.brave.com' + } + }) + assert.deepEqual( + nextState.tabs[this.tabId].adsBlockedResources, + [ + 'https://test.brave.com', + 'https://test2.brave.com' + ] + ) + + nextState = shieldsPanelReducer(nextState, { + type: types.RESOURCE_BLOCKED, + details: { + blockType: 'ads', + tabId: this.tabId, + subresource: 'https://test2.brave.com' + } + }) + assert.deepEqual( + nextState.tabs[this.tabId].adsBlockedResources, + [ + 'https://test.brave.com', + 'https://test2.brave.com' + ] + ) + }) + it('increases different tab counts separately', function () { let nextState = deepFreeze(shieldsPanelReducer(state, { type: types.RESOURCE_BLOCKED,