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

Commit 4cebfe6

Browse files
committed
fix extension state tests
auditors: @bbondy
1 parent 46f87a6 commit 4cebfe6

File tree

1 file changed

+14
-8
lines changed

1 file changed

+14
-8
lines changed

test/unit/common/state/extensionStateTest.js

+14-8
Original file line numberDiff line numberDiff line change
@@ -274,22 +274,26 @@ describe('extensionState', function () {
274274
})
275275

276276
describe('getBrowserActionByTabId', function () {
277+
before(function () {
278+
this.state = defaultAppState.setIn(['extensions', 'abcd'],
279+
abcdBrowserAction.setIn(['browserAction', 'tabs', '1'], Immutable.fromJS({
280+
title: 'tabTitle'
281+
})))
282+
})
283+
277284
describe('without tab-specific properties', function () {
278285
before(function () {
279-
this.state = defaultAppState.setIn(['extensions', 'abcd'], abcdBrowserAction)
280286
this.browserAction = extensionState.getBrowserActionByTabId(this.state, 'abcd', '1')
281287
})
282288

283289
it('should return the default browserAction properties', function () {
284-
assert(Immutable.is(this.browserAction, abcdBrowserAction.get('browserAction')))
290+
assert.equal(this.browserAction.get('title'), abcdBrowserAction.getIn(['browserAction', 'title']))
291+
assert.equal(this.browserAction.get('popup'), abcdBrowserAction.getIn(['browserAction', 'popup']))
285292
})
286293
})
287294

288295
describe('with tab-specific properties', function () {
289296
before(function () {
290-
this.state = defaultAppState.setIn(['extensions', 'abcd'], abcdBrowserAction.setIn(['browserAction', 'tabs', '1'], Immutable.fromJS({
291-
title: 'tabTitle'
292-
})))
293297
this.browserAction = extensionState.getBrowserActionByTabId(this.state, 'abcd', '1')
294298
})
295299

@@ -301,12 +305,14 @@ describe('extensionState', function () {
301305

302306
describe('no browser action for the extensionId', function () {
303307
before(function () {
304-
this.state = defaultAppState.setIn(['extensions', 'abcd'], abcdBrowserAction)
305-
this.browserAction = extensionState.getBrowserActionByTabId(this.state, 'abcd', '1')
308+
let state = this.state.setIn(['extensions', 'abcde'], Immutable.fromJS({}))
309+
this.browserAction1 = extensionState.getBrowserActionByTabId(state, 'abcde', '1')
310+
this.browserAction2 = extensionState.getBrowserActionByTabId(state, 'abcdef', '1')
306311
})
307312

308313
it('should return null', function () {
309-
assert(this.browserAction, null)
314+
assert.equal(this.browserAction1, null)
315+
assert.equal(this.browserAction2, null)
310316
})
311317
})
312318
})

0 commit comments

Comments
 (0)