+ describe("Ext.emptyFn", function() {
+ it("should return undefined without params", function() {
+ expect(Ext.emptyFn()).toBeUndefined();
+ });
+
+ it("should return undefined if you pass params", function() {
+ expect(Ext.emptyFn('aaaa', 'bbbbb')).toBeUndefined();
+ });
+ });
+
+ describe("Ext.iterate", function() {
+ var itFn;
+
+ beforeEach(function() {
+ itFn = jasmine.createSpy();
+ });
+
+ describe("iterate object", function() {
+ var o;
+
+ beforeEach(function() {
+ o = {
+ n1: 11,
+ n2: 13,
+ n3: 18
+ };
+ });
+
+ describe("if itFn does not return false", function() {
+ beforeEach(function() {
+ Ext.iterate(o, itFn);
+ });
+
+ it("should call the iterate function 3 times", function () {
+ expect(itFn.callCount).toEqual(3);
+ });
+
+ it("should call the iterate function with correct arguments", function () {
+ expect(itFn.calls[0].args).toEqual(["n1", 11, o]);
+ expect(itFn.calls[1].args).toEqual(["n2", 13, o]);
+ expect(itFn.calls[2].args).toEqual(["n3", 18, o]);
+ });
+ });
+
+ describe("if itFn return false", function() {
+ beforeEach(function() {
+ itFn.andReturn(false);
+ Ext.iterate(o, itFn);
+ });
+
+ it("should stop iteration if function return false", function() {
+ itFn.andReturn(false);
+
+ expect(itFn.calls.length).toEqual(1);
+ });
+ });
+ });
+
+ describe("do nothing on an empty object", function() {
+ var o;
+
+ beforeEach(function() {
+ o = {};
+ Ext.iterate(o, itFn);
+ });
+
+ it("should not call the iterate function", function () {
+ expect(itFn).not.toHaveBeenCalled();
+ });
+
+ });
+
+ describe("iterate array", function() {
+ var arr;
+
+ beforeEach(function() {
+ arr = [6, 7, 8, 9];
+ });
+
+ describe("if itFn does not return false", function() {
+ beforeEach(function() {
+ Ext.iterate(arr, itFn);
+ });
+
+ it("should call the iterate function 4 times", function () {
+ expect(itFn.callCount).toEqual(4);
+ });
+
+ it("should call the iterate function with correct arguments", function () {
+ expect(itFn.calls[0].args).toEqual([6, 0, arr]);
+ expect(itFn.calls[1].args).toEqual([7, 1, arr]);
+ expect(itFn.calls[2].args).toEqual([8, 2, arr]);
+ expect(itFn.calls[3].args).toEqual([9, 3, arr]);
+ });
+ });
+
+ describe("if itFn return false", function() {
+ beforeEach(function() {
+ itFn.andReturn(false);
+ Ext.iterate(arr, itFn);
+ });
+
+ it("should stop iteration if function return false", function() {
+ itFn.andReturn(false);
+
+ expect(itFn.calls.length).toEqual(1);
+ });
+ });
+ });
+
+ describe("do nothing on an empty array", function() {
+ var arr;
+
+ beforeEach(function() {
+ arr = [];
+ Ext.iterate(arr, itFn);
+ });
+
+ it("should not call the iterate function", function () {
+ expect(itFn).not.toHaveBeenCalled();
+ });
+
+ });
+ });
+