aboutsummaryrefslogtreecommitdiffstats
path: root/test/auto/injectorSpec.js
diff options
context:
space:
mode:
authorVojta Jina2013-10-16 12:14:44 -0700
committerIgor Minar2013-10-18 15:26:51 -0700
commitc22adbf160f32c1839fbb35382b7a8c6bcec2927 (patch)
tree3e4937b777958f1c4c0c9300e4065805a06ae29c /test/auto/injectorSpec.js
parentdba566a96d3c660e12249dcb6445dad19854da97 (diff)
downloadangular.js-c22adbf160f32c1839fbb35382b7a8c6bcec2927.tar.bz2
fix($injector): allow a constructor function to return a function
This change makes `$injector.instantiate` (and thus `$provide.service`) to behave the same as native `new` operator.
Diffstat (limited to 'test/auto/injectorSpec.js')
-rw-r--r--test/auto/injectorSpec.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/test/auto/injectorSpec.js b/test/auto/injectorSpec.js
index 5c186cf1..aea2dee7 100644
--- a/test/auto/injectorSpec.js
+++ b/test/auto/injectorSpec.js
@@ -788,6 +788,16 @@ describe('injector', function() {
});
+ it('should allow constructor to return a function', function() {
+ var fn = function() {};
+ var Class = function() {
+ return fn;
+ };
+
+ expect($injector.instantiate(Class)).toBe(fn);
+ });
+
+
it('should handle constructor exception', function() {
expect(function() {
$injector.instantiate(function() { throw 'MyError'; });