-
Notifications
You must be signed in to change notification settings - Fork 171
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit test for controller using the regServices. This closes #27
- Loading branch information
Marcos Lin
committed
May 28, 2014
1 parent
cf8c0ff
commit c40bc19
Showing
5 changed files
with
70 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
/*jslint nomen: true */ | ||
/*globals define, angular */ | ||
|
||
define(['app','regServices'], function (app) { | ||
'use strict'; | ||
var ctrl_name = "RegController"; | ||
app.register.controller(ctrl_name, ['$scope', 'UtestRegFactory', 'UtestRegService', function ($scope, UtestRegFactory, UtestRegService) { | ||
$scope.ctrl_name = ctrl_name; | ||
$scope.utest_reg_factory = UtestRegFactory; | ||
$scope.utest_reg_service = UtestRegService; | ||
}]); | ||
|
||
// Return expected unit test result | ||
app.__utest_ctrl_result = { | ||
"ctrl_name": ctrl_name | ||
}; | ||
|
||
return app; | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
/*jslint browser: true, devel: true, node: true, nomen: true */ | ||
/*globals define, angular, describe, expect, it */ | ||
|
||
/** | ||
* Testing declaration of controller following require.js spec and make sure | ||
* it's dependecies are loaded. | ||
*/ | ||
define(['regController', 'angularAMD'], function (app, angularAMD) { | ||
'use strict'; | ||
describe('Utest RegController', function () { | ||
//console.log("Running controllerSpec.js"); | ||
var ctrl_name = app.__utest_ctrl_result.ctrl_name, | ||
scope, service_results, ctrl; | ||
|
||
angularAMD.inject(function ($rootScope, $controller, UtestRegServiceResult) { | ||
scope = $rootScope.$new(); | ||
service_results = UtestRegServiceResult; | ||
ctrl = $controller(ctrl_name, { $scope: scope }); | ||
}); | ||
|
||
it("service_results should exists.", function () { | ||
expect(service_results).toBeDefined(); | ||
}); | ||
|
||
it("scope.ctrl_name check", function () { | ||
expect(scope.ctrl_name).toBe(ctrl_name); | ||
}); | ||
|
||
it("scope.utest_factory check", function () { | ||
var f = scope.utest_reg_factory; | ||
expect(f.name).toBe(service_results.factory_name); | ||
expect(f.const_name).toBe(service_results.reg_constant_name); | ||
}); | ||
|
||
it("scope.utest_service check", function () { | ||
var s = scope.utest_reg_service; | ||
expect(s.name).toBe(service_results.service_name); | ||
expect(s.val_name).toBe(service_results.reg_value_name); | ||
}); | ||
|
||
}); | ||
}); |