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

Commit

Permalink
add tests for tabContentState and create tabUtilTest
Browse files Browse the repository at this point in the history
  • Loading branch information
cezaraugusto committed Jul 26, 2017
1 parent fe8c036 commit 96f5da4
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 0 deletions.
22 changes: 22 additions & 0 deletions test/unit/app/common/state/tabContentStateTest.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,6 +429,18 @@ describe('tabContentState unit tests', function () {
})
assert.equal(tabContentState.hasFixedCloseIcon(), false)
})

it('frame is active and breakpoint is dynamic', function () {
getFrameByKeyMock = sinon.stub(frameStateUtil, 'getFrameByKey', () => {
return Immutable.fromJS({
breakpoint: 'dynamic'
})
})
isFrameKeyActive = sinon.stub(frameStateUtil, 'isFrameKeyActive', () => {
return true
})
assert.equal(tabContentState.hasFixedCloseIcon(), false)
})
})

describe('hasRelativeCloseIcon', function () {
Expand Down Expand Up @@ -461,6 +473,16 @@ describe('tabContentState unit tests', function () {
})
assert.equal(tabContentState.hasRelativeCloseIcon(state, frameKey), true)
})

it('if hovering (tabIndex === hoverTabIndex) and break point is dynamic', function () {
const state = defaultWindowStore
getFrameByKeyMock = sinon.stub(frameStateUtil, 'getFrameByKey', () => {
return Immutable.fromJS({
breakpoint: 'dynamic'
})
})
assert.equal(tabContentState.hasRelativeCloseIcon(state, frameKey), true)
})
})

describe('hasVisibleSecondaryIcon', function () {
Expand Down
49 changes: 49 additions & 0 deletions test/unit/lib/tabUtilTest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/* global describe, it */
const tabUtil = require('../../../app/renderer/lib/tabUtil')
const tabBreakpoint = require('../../../app/renderer/components/styles/global').breakpoint.tab
const assert = require('assert')

require('../braveUnit')

describe('tabUtil', function () {
describe('getTabBreakpoint', function () {
let size

it('returns `dynamic` if `dynamic` size matches', function () {
size = Number.parseInt(tabBreakpoint.dynamic, 10)
assert.equal(tabUtil.getTabBreakpoint(size), 'dynamic')
})
it('returns `default` if `default` size matches', function () {
size = Number.parseInt(tabBreakpoint.default, 10)
assert.equal(tabUtil.getTabBreakpoint(size), 'default')
})
it('returns `large` if `large` size matches', function () {
size = Number.parseInt(tabBreakpoint.large, 10)
assert.equal(tabUtil.getTabBreakpoint(size), 'large')
})
it('returns `largeMedium` if `largeMedium` size matches', function () {
size = Number.parseInt(tabBreakpoint.largeMedium, 10)
assert.equal(tabUtil.getTabBreakpoint(size), 'largeMedium')
})
it('returns `medium` if `medium` size matches', function () {
size = Number.parseInt(tabBreakpoint.medium, 10)
assert.equal(tabUtil.getTabBreakpoint(size), 'medium')
})
it('returns `mediumSmall` if `mediumSmall` size matches', function () {
size = Number.parseInt(tabBreakpoint.mediumSmall, 10)
assert.equal(tabUtil.getTabBreakpoint(size), 'mediumSmall')
})
it('returns `small` if `small` size matches', function () {
size = Number.parseInt(tabBreakpoint.small, 10)
assert.equal(tabUtil.getTabBreakpoint(size), 'small')
})
it('returns `extraSmall` if `extraSmall` size matches', function () {
size = Number.parseInt(tabBreakpoint.extraSmall, 10)
assert.equal(tabUtil.getTabBreakpoint(size), 'extraSmall')
})
it('returns `smallest` if `smallest` size matches', function () {
size = Number.parseInt(tabBreakpoint.smallest, 10)
assert.equal(tabUtil.getTabBreakpoint(size), 'smallest')
})
})
})

0 comments on commit 96f5da4

Please sign in to comment.