From a87f2fb9e4d65ac5d260e914b5e31aa0e0f47b2c Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Fri, 4 Nov 2011 12:33:01 -0700 Subject: refactor(mock): moved mocks into its own module --- test/angular-mocksSpec.js | 54 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 54 insertions(+) (limited to 'test/angular-mocksSpec.js') 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('
abc
xyz'); + expect(d(e).toLowerCase()).toEqual('
abc
xyz'); + expect(d(e[0]).toLowerCase()).toEqual('
abc
'); + }); + + 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); + }); + }); }); -- cgit v1.2.3