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 assert = chai.assert
sinon.assert.expose assert, prefix: null
describe "AnnotationViewerController", ->
describe 'AnnotationViewerController', ->
annotationViewerController = null
before -> before ->
angular.module('h', ['ngRoute']) angular.module("h", [])
.controller('AnnotationViewerController', require('../annotation-viewer-controller')) .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) -> # Return a new AnnotationViewerController instance.
$scope = $rootScope.$new() createAnnotationViewerController = ({$location, $routeParams, $scope,
$scope.search = {} streamer, store, streamFilter,
annotationViewerController = $controller 'AnnotationViewerController', annotationMapper}) ->
$scope: $scope 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', -> it "sets the isEmbedded property to false", ->
assert.isFalse($scope.isEmbedded) {$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