Commit 47a03b87 authored by Sean Hammond's avatar Sean Hammond

Fix annotation-viewer-controller-test.coffee

The single it() in this test module was not being run (it was indented
inside a beforeEach()) and dedenting it reveals that the beforeEach() is
actually crashing anyway (controller somehow not registering with the
$controller service, looks like).

Rewrite the module to work and be clearer.
parent e66dea81
{module, inject} = require('angular-mock')
{inject, module} = require('angular-mock')
assert = chai.assert
sinon.assert.expose assert, prefix: null
describe 'AnnotationViewerController', ->
annotationViewerController = null
describe "AnnotationViewerController", ->
before ->
angular.module('h', ['ngRoute'])
.controller('AnnotationViewerController', require('../annotation-viewer-controller'))
angular.module("h", [])
.controller(
'AnnotationViewerController',
require('../annotation-viewer-controller'))
beforeEach(module("h"))
# Return the $controller service from Angular.
getControllerService = ->
$controller = null
inject((_$controller_) ->
$controller = _$controller_
)
return $controller
beforeEach inject ($controller, $rootScope) ->
$scope = $rootScope.$new()
$scope.search = {}
annotationViewerController = $controller 'AnnotationViewerController',
$scope: $scope
# Return a new AnnotationViewerController instance.
createAnnotationViewerController = ({$location, $routeParams, $scope,
streamer, store, streamFilter,
annotationMapper}) ->
locals = {
$location: $location or {}
$routeParams: $routeParams or {id: "test_annotation_id"}
$scope: $scope or {search: {}}
streamer: streamer or {send: ->}
store: store or {
AnnotationResource: {read: ->},
SearchResource: {get: ->}}
streamFilter: streamFilter or {
setMatchPolicyIncludeAny: -> {addClause: -> {addClause: ->}}
getFilter: ->
}
annotationMapper: annotationMapper or {}
}
locals["ctrl"] = getControllerService()(
"AnnotationViewerController", locals)
return locals
it 'sets the isEmbedded property to false', ->
assert.isFalse($scope.isEmbedded)
it "sets the isEmbedded property to false", ->
{$scope} = createAnnotationViewerController({})
assert.isFalse($scope.isEmbedded)
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