|
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<% } %>) { |
17 |
| - $httpBackend = _$httpBackend_; |
18 |
| - $httpBackend.expectGET('/api/things') |
19 |
| - .respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']); |
| 16 | + beforeEach(inject(function( |
| 17 | + _$httpBackend_, |
| 18 | + $http, |
| 19 | + $componentController, |
| 20 | + $rootScope<% if (filters.uirouter) {%>, |
| 21 | + $state<% } %><% if (filters.socketio) {%>, |
| 22 | + socket<% } %>) { |
| 23 | + $httpBackend = _$httpBackend_; |
| 24 | + $httpBackend.expectGET('/api/things') |
| 25 | + .respond(['HTML5 Boilerplate', 'AngularJS', 'Karma', 'Express']); |
20 | 26 |
|
21 |
| - scope = $rootScope.$new();<% if (filters.uirouter) {%> |
22 |
| - state = $state;<% } %> |
23 |
| - MainController = $controller('MainController', { |
24 |
| - $scope: scope |
25 |
| - }); |
| 27 | + scope = $rootScope.$new();<% if (filters.uirouter) {%> |
| 28 | + state = $state;<% } %> |
| 29 | + mainComponent = $componentController('main', { |
| 30 | + $http: $http, |
| 31 | + $scope: scope<% if (filters.socketio) {%>, |
| 32 | + socket: socket<% } %> |
| 33 | + }); |
26 | 34 | }));
|
27 | 35 |
|
28 | 36 | it('should attach a list of things to the controller', function() {
|
| 37 | + mainComponent.$onInit(); |
29 | 38 | $httpBackend.flush();<% if (filters.jasmine) { %>
|
30 |
| - expect(MainController.awesomeThings.length).toBe(4);<% } if (filters.mocha) { %> |
31 |
| - <%= expect() %>MainController.awesomeThings.length<%= to() %>.equal(4);<% } %> |
| 39 | + expect(mainComponent.awesomeThings.length).toBe(4);<% } if (filters.mocha) { %> |
| 40 | + <%= expect() %>mainComponent.awesomeThings.length<%= to() %>.equal(4);<% } %> |
32 | 41 | });
|
33 | 42 | });
|
0 commit comments