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

Commit

Permalink
add security controls test
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Oct 11, 2018
1 parent e3f84bd commit 0e61fea
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 4 deletions.
8 changes: 4 additions & 4 deletions app/components/braveShields/securityControls.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import { Stat, GridLabel } from 'brave-ui/features/shields'
import { BlockOptions } from '../../types/other/blockTypes'
import { getMessage } from '../../background/api/localeAPI'

interface Props {
export interface Props {
braveShields: BlockOptions
httpsRedirected: number
}
Expand All @@ -19,18 +19,18 @@ export default class ShieldsSecurityControls extends React.PureComponent<Props,
return null
}
return (
<>
<div id='braveShieldsSecurityControls'>
{/* pishing toggle
<GridLabel>
<Stat />
{getMessage('blockPishing')}
</GridLabel> */}
{/* connections encrypted toggle */}
<GridLabel>
<Stat>{httpsRedirected}</Stat>
<Stat id='httpsRedirectedStat'>{httpsRedirected}</Stat>
{getMessage('connectionsEncrypted')}
</GridLabel>
</>
</div>
)
}
}
35 changes: 35 additions & 0 deletions test/app/components/braveShields/securityControlsTest.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
/* global describe, it */
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/. */

import 'mocha'
import * as React from 'react'
import * as assert from 'assert'
import ShieldsSecurityControls, { Props } from '../../../../app/components/braveShields/securityControls'
import { shallow } from 'enzyme'

const fakeProps: Props = {
braveShields: 'allow',
httpsRedirected: 0
}

describe('SecurityControls component', () => {
const baseComponent = (props: Props) =>
<ShieldsSecurityControls {...props} />

it('renders the component', () => {
const wrapper = shallow(baseComponent(fakeProps))
const assertion = wrapper.find('#braveShieldsSecurityControls').length === 1
assert.equal(assertion, true)
})

describe('https everywhere', () => {
it('shows number of https redirected', () => {
const newProps = Object.assign(fakeProps, { httpsRedirected: 1337 })
const wrapper = shallow(baseComponent(newProps))
const assertion = wrapper.find('#httpsRedirectedStat').props().children
assert.equal(assertion, 1337)
})
})
})

0 comments on commit 0e61fea

Please sign in to comment.