Commit 7ee3c828 authored by Robert Knight's avatar Robert Knight

Couple of minor simplifications

 * Avoid a loop over an array with a single entry

 * Avoid an unnecessary variable shared between multiple
   tests
parent a0b4e76b
......@@ -47,12 +47,9 @@ module.exports = class AppController
}
# Reload the view when the user switches accounts
reloadEvents = [events.USER_CHANGED];
reloadEvents.forEach((eventName) ->
$scope.$on(eventName, (event, data) ->
if !data || !data.initialLoad
$route.reload()
)
$scope.$on(events.USER_CHANGED, (event, data) ->
if !data || !data.initialLoad
$route.reload()
);
identity.watch({
......
......@@ -42,8 +42,6 @@ describe 'WidgetController', ->
unsaved: sandbox.stub()
}
lastSearchResult = null
fakeStore = {
SearchResource:
get: (query, callback) ->
......@@ -52,7 +50,6 @@ describe 'WidgetController', ->
result =
total: 100
rows: [offset..offset+limit-1]
lastSearchResult = result
callback result
}
......@@ -112,11 +109,15 @@ describe 'WidgetController', ->
it 'should load annotations for the new group', ->
fakeThreading.annotationList = sandbox.stub().returns([{id: '1'}])
fakeCrossFrame.frames.push({uri: 'http://example.com'})
searchResult = {total: 10, rows: [0..10]}
fakeStore.SearchResource.get = (query, callback) ->
callback(searchResult)
$scope.$broadcast(events.GROUP_FOCUSED)
assert.calledWith(fakeAnnotationMapper.unloadAnnotations,
[{id: '1'}])
$scope.$digest();
assert.calledWith(fakeAnnotationMapper.loadAnnotations,
lastSearchResult.rows)
searchResult.rows)
assert.calledWith(fakeThreading.thread, fakeDrafts.unsaved())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment