diff options
| author | Misko Hevery | 2011-11-04 12:33:01 -0700 |
|---|---|---|
| committer | Misko Hevery | 2011-11-14 20:31:14 -0800 |
| commit | a87f2fb9e4d65ac5d260e914b5e31aa0e0f47b2c (patch) | |
| tree | 93e69475affd24ef5b16c68e47d1476bc37787a7 /test/angular-mocksSpec.js | |
| parent | c27aba4354c69c4a67fab587a59a8079cc9edc91 (diff) | |
| download | angular.js-a87f2fb9e4d65ac5d260e914b5e31aa0e0f47b2c.tar.bz2 | |
refactor(mock): moved mocks into its own module
Diffstat (limited to 'test/angular-mocksSpec.js')
| -rw-r--r-- | test/angular-mocksSpec.js | 54 |
1 files changed, 54 insertions, 0 deletions
diff --git a/test/angular-mocksSpec.js b/test/angular-mocksSpec.js index b4ceb275..1668d500 100644 --- a/test/angular-mocksSpec.js +++ b/test/angular-mocksSpec.js @@ -283,4 +283,58 @@ describe('mocks', function() { }).toThrow("Unknown mode 'XXX', only 'log'/'rethrow' modes are allowed!"); })); }); + + + describe('angular.mock.debug', function(){ + var d = angular.mock.dump; + + + it('should serialize primitive types', function(){ + expect(d(undefined)).toEqual('undefined'); + expect(d(1)).toEqual('1'); + expect(d(null)).toEqual('null'); + expect(d('abc')).toEqual('abc'); + }); + + + it('should serialize element', function(){ + var e = angular.element('<div>abc</div><span>xyz</span>'); + expect(d(e).toLowerCase()).toEqual('<div>abc</div><span>xyz</span>'); + expect(d(e[0]).toLowerCase()).toEqual('<div>abc</div>'); + }); + + it('should serialize scope', inject(function($rootScope){ + $rootScope.obj = {abc:'123'}; + expect(d($rootScope)).toMatch(/Scope\(.*\): \{/); + expect(d($rootScope)).toMatch(/{"abc":"123"}/); + })); + + + it('should be published on window', function(){ + expect(window.dump instanceof Function).toBe(true); + }); + }); + + describe('jasmine inject', function(){ + it('should call invoke', function(){ + var count = 0; + function fn1(){ + expect(this).toBe(self); + count++; + } + function fn2(){ + expect(this).toBe(self); + count++; + } + var fn = inject(fn1, fn2); + var self = { + $injector: { + invoke: function(self, fn) { fn.call(self); } + } + }; + + fn.call(self); + expect(count).toBe(2); + }); + }); }); |
