|
1 | 1 | 'use strict'; |
2 | 2 |
|
3 | | -describe('Controller: MainController', function() { |
| 3 | +describe('Component: mainComponent', function() { |
4 | 4 |
|
5 | 5 | // load the controller's module |
6 | 6 | beforeEach(module('<%= scriptAppName %>'));<% if (filters.uirouter) {%> |
7 | 7 | beforeEach(module('stateMock'));<% } %><% if (filters.socketio) {%> |
8 | 8 | beforeEach(module('socketMock'));<% } %> |
9 | 9 |
|
10 | 10 | var scope; |
11 | | - var MainController;<% if (filters.uirouter) {%> |
| 11 | + var mainComponent;<% if (filters.uirouter) {%> |
12 | 12 | var state;<% } %> |
13 | 13 | var $httpBackend; |
14 | 14 |
|
15 | 15 | // Initialize the controller and a mock scope |
16 | | - beforeEach(inject(function(_$httpBackend_, $controller, $rootScope<% if (filters.uirouter) {%>, $state<% } %>) { |
| 16 | + beforeEach(inject(function(_$httpBackend_, $http, $componentController, $rootScope<% if (filters.uirouter) {%>, $state<% } %><% if (filters.socketio) {%>, socket<% } %>) { |
17 | 17 | $httpBackend = _$httpBackend_; |
18 | 18 | $httpBackend.expectGET('/api/things') |
19 | 19 | .respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']); |
20 | 20 |
|
21 | 21 | scope = $rootScope.$new();<% if (filters.uirouter) {%> |
22 | 22 | state = $state;<% } %> |
23 | | - MainController = $controller('MainController', { |
24 | | - $scope: scope |
| 23 | + mainComponent = $componentController('main', { |
| 24 | + $http: $http, |
| 25 | + $scope: scope<% if (filters.socketio) {%>, |
| 26 | + socket: socket<% } %> |
25 | 27 | }); |
26 | 28 | })); |
27 | 29 |
|
28 | 30 | it('should attach a list of things to the controller', function() { |
| 31 | + mainComponent.$onInit(); |
29 | 32 | $httpBackend.flush();<% if (filters.jasmine) { %> |
30 | | - expect(MainController.awesomeThings.length).toBe(4);<% } if (filters.mocha) { %> |
31 | | - <%= expect() %>MainController.awesomeThings.length<%= to() %>.equal(4);<% } %> |
| 33 | + expect(mainComponent.awesomeThings.length).toBe(4);<% } if (filters.mocha) { %> |
| 34 | + <%= expect() %>mainComponent.awesomeThings.length<%= to() %>.equal(4);<% } %> |
32 | 35 | }); |
33 | 36 | }); |
0 commit comments