diff options
Diffstat (limited to 'test/AngularSpec.js')
| -rw-r--r-- | test/AngularSpec.js | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/test/AngularSpec.js b/test/AngularSpec.js new file mode 100644 index 00000000..de724f03 --- /dev/null +++ b/test/AngularSpec.js @@ -0,0 +1,52 @@ +describe('Angular', function(){ + xit('should fire on updateEvents', function(){ + var onUpdateView = jasmine.createSpy(); + var scope = angular.compile("<div></div>", { onUpdateView: onUpdateView }); + expect(onUpdateView).wasNotCalled(); + scope.$init(); + scope.$eval(); + expect(onUpdateView).wasCalled(); + }); +}); + +describe("copy", function(){ + it("should return same object", function (){ + var obj = {}; + var arr = []; + assertSame(obj, copy({}, obj)); + assertSame(arr, copy([], arr)); + }); + + it("should copy array", function(){ + var src = [1, {name:"value"}]; + var dst = [{key:"v"}]; + assertSame(dst, copy(src, dst)); + assertEquals([1, {name:"value"}], dst); + assertEquals({name:"value"}, dst[1]); + assertNotSame(src[1], dst[1]); + }); + + it('should copy empty array', function() { + var src = []; + var dst = [{key: "v"}]; + assertEquals([], copy(src, dst)); + assertEquals([], dst); + }); + + it("should copy object", function(){ + var src = {a:{name:"value"}}; + var dst = {b:{key:"v"}}; + assertSame(dst, copy(src, dst)); + assertEquals({a:{name:"value"}}, dst); + assertEquals(src.a, dst.a); + assertNotSame(src.a, dst.a); + }); + + it("should copy primitives", function(){ + expect(copy(null)).toEqual(null); + expect(copy('')).toEqual(''); + expect(copy(123)).toEqual(123); + expect(copy([{key:null}])).toEqual([{key:null}]); + }); + +}); |
