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

Commit

Permalink
rev1 of siteSettingsReducerTest
Browse files Browse the repository at this point in the history
Auditors: @NejcZdovc
  • Loading branch information
bsclifton authored and NejcZdovc committed Sep 22, 2017
1 parent 40d2d96 commit 2cb1122
Showing 1 changed file with 83 additions and 0 deletions.
83 changes: 83 additions & 0 deletions test/unit/app/browser/reducers/siteSettingsReducerTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
/* global describe, it, before, after */
const mockery = require('mockery')
const sinon = require('sinon')
const Immutable = require('immutable')
const assert = require('assert')
const fakeElectron = require('../../../lib/fakeElectron')

const appConstants = require('../../../../../js/constants/appConstants')
require('../../../braveUnit')

describe('siteSettingsReducer unit tests', function () {
let siteSettingsReducer
let siteSettings

before(function () {
mockery.enable({
warnOnReplace: false,
warnOnUnregistered: false,
useCleanCache: true
})

mockery.registerMock('electron', fakeElectron)
siteSettings = require('../../../../../js/state/siteSettings')
mockery.registerMock('../../../js/state/siteSettings', siteSettings)

siteSettingsReducer = require('../../../../../app/browser/reducers/siteSettingsReducer')
})

after(function () {
mockery.disable()
})

describe('APP_ALLOW_FLASH_ONCE', function () {
let fakeAppState
let mergeSiteSettingSpy

before(function () {
mergeSiteSettingSpy = sinon.spy(siteSettings, 'mergeSiteSetting')
fakeAppState = Immutable.fromJS({
siteSettings: {
regularTabSetting: ''
},
temporarySiteSettings: {
privateTabSetting: ''
}
})
})
after(function () {
mergeSiteSettingSpy.restore()
})
it('merges setting into siteSettings if regular tab', function () {
siteSettingsReducer(fakeAppState, Immutable.fromJS({
actionType: appConstants.APP_ALLOW_FLASH_ONCE,
isPrivate: false,
url: 'https://example.com/test/page.html'
}))
assert(mergeSiteSettingSpy.withArgs(fakeAppState.get('siteSettings'), 'https://example.com', 'flash', 1).calledOnce)
})
it('merges setting into siteSettings if private tab', function () {
siteSettingsReducer(fakeAppState, Immutable.fromJS({
actionType: appConstants.APP_ALLOW_FLASH_ONCE,
isPrivate: true,
url: 'https://example.com/test/page.html'
}))
assert(mergeSiteSettingSpy.withArgs(fakeAppState.get('temporarySiteSettings'), 'https://example.com', 'flash', 1).calledOnce)
})
})

describe('APP_ALLOW_FLASH_ALWAYS', function () {
})

describe('APP_CHANGE_SITE_SETTING', function () {
})

describe('APP_REMOVE_SITE_SETTING', function () {
})

describe('APP_CLEAR_SITE_SETTINGS', function () {
})

describe('APP_ADD_NOSCRIPT_EXCEPTIONS', function () {
})
})

0 comments on commit 2cb1122

Please sign in to comment.