aboutsummaryrefslogtreecommitdiffstats
path: root/test/InjectorSpec.js
diff options
context:
space:
mode:
authorVojta Jina2012-03-08 16:53:15 -0800
committerVojta Jina2012-03-09 10:10:29 -0800
commit0bfaa579c04d1b7cd21fbe16bfbc47a684f223b3 (patch)
tree1e6c2147eed623ea9d17570511df1586a0af8449 /test/InjectorSpec.js
parent00d4427388eeec81d434f9ee96bb7ccc70190923 (diff)
downloadangular.js-0bfaa579c04d1b7cd21fbe16bfbc47a684f223b3.tar.bz2
feat($provide.service): Add $provide.service() for registering a class
Diffstat (limited to 'test/InjectorSpec.js')
-rw-r--r--test/InjectorSpec.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/test/InjectorSpec.js b/test/InjectorSpec.js
index b0682b29..cc5c5b50 100644
--- a/test/InjectorSpec.js
+++ b/test/InjectorSpec.js
@@ -315,6 +315,38 @@ describe('injector', function() {
});
+ describe('service', function() {
+ it('should register a class', function() {
+ var Type = function(value) {
+ this.value = value;
+ };
+
+ var instance = createInjector([function($provide) {
+ $provide.value('value', 123);
+ $provide.service('foo', Type);
+ }]).get('foo');
+
+ expect(instance instanceof Type).toBe(true);
+ expect(instance.value).toBe(123);
+ });
+
+
+ it('should register a set of classes', function() {
+ var Type = function() {};
+
+ var injector = createInjector([function($provide) {
+ $provide.service({
+ foo: Type,
+ bar: Type
+ });
+ }]);
+
+ expect(injector.get('foo') instanceof Type).toBe(true);
+ expect(injector.get('bar') instanceof Type).toBe(true);
+ });
+ });
+
+
describe('provider', function() {
it('should configure $provide provider object', function() {
expect(createInjector([function($provide) {