aboutsummaryrefslogtreecommitdiffstats
path: root/test/service/controllerSpec.js
blob: 8b12eceb283c90d9b5ea2b13d98de430dc3d0543 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
'use strict';

describe('$controller', function() {
  var $controller;

  beforeEach(inject(function($injector) {
    $controller = $injector.get('$controller');
  }));

  it('should return instance of given controller class', function() {
    var MyClass = function() {},
        ctrl = $controller(MyClass);

    expect(ctrl).toBeDefined();
    expect(ctrl instanceof MyClass).toBe(true);
  });

  it('should inject arguments', inject(function($http) {
    var MyClass = function($http) {
      this.$http = $http;
    };

    var ctrl = $controller(MyClass);
    expect(ctrl.$http).toBe($http);
  }));


  it('should inject given scope', function() {
    var MyClass = function($scope) {
      this.$scope = $scope;
    };

    var scope = {},
        ctrl = $controller(MyClass, scope);

    expect(ctrl.$scope).toBe(scope);
  });
});