Installed leaflet in extlib
[mediagoblin.git] / extlib / leaflet / spec / suites / core / UtilSpec.js
diff --git a/extlib/leaflet/spec/suites/core/UtilSpec.js b/extlib/leaflet/spec/suites/core/UtilSpec.js
new file mode 100644 (file)
index 0000000..46cb8fb
--- /dev/null
@@ -0,0 +1,63 @@
+describe('Util', function() {\r
+\r
+       describe('#extend', function() {\r
+               var a;\r
+               \r
+               beforeEach(function() {\r
+                       a = {\r
+                               foo: 5,\r
+                               bar: 'asd'\r
+                       };\r
+               });\r
+               \r
+               it('should extend the first argument with the properties of the second', function() {\r
+                       L.Util.extend(a, {\r
+                               bar: 7,\r
+                               baz: 3\r
+                       });\r
+                       \r
+                       expect(a).toEqual({\r
+                               foo: 5,\r
+                               bar: 7,\r
+                               baz: 3\r
+                       });\r
+               });\r
+               \r
+               it('should work with more than 2 arguments', function() {\r
+                       L.Util.extend(a, {bar: 7}, {baz: 3});\r
+                       \r
+                       expect(a).toEqual({\r
+                               foo: 5,\r
+                               bar: 7,\r
+                               baz: 3\r
+                       });\r
+               });\r
+       });\r
+\r
+       describe('#bind', function() {\r
+               it('should return the given function with the given context', function() {\r
+                       var fn = function() {\r
+                               return this;\r
+                       };\r
+                       \r
+                       var fn2 = L.Util.bind(fn, 5);\r
+                       \r
+                       expect(fn2()).toEqual(5);\r
+               });\r
+       });\r
+       \r
+       describe('#stamp', function() {\r
+               it('should set a unique id on the given object and return it', function() {\r
+                       var a = {},\r
+                               id = L.Util.stamp(a);\r
+                       \r
+                       expect(typeof id).toEqual('number');\r
+                       expect(L.Util.stamp(a)).toEqual(id);\r
+                       \r
+                       var b = {},\r
+                               id2 = L.Util.stamp(b);\r
+                       \r
+                       expect(id2).not.toEqual(id);\r
+               });\r
+       });\r
+});
\ No newline at end of file