You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/03/03 13:29:49 UTC

[04/10] brooklyn-ui git commit: Fixes due to Jasmine 2.x API changes

Fixes due to Jasmine 2.x API changes

* spyOn(*).andCallThrough() -> spyOn(*).and.callThrough()
* wait(*) run(*) has been removed in favour of standard setTimeout(**)


Project: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/commit/ab9d62ca
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/tree/ab9d62ca
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-ui/diff/ab9d62ca

Branch: refs/heads/master
Commit: ab9d62ca0b7b724d89e09ba2ef0d45b1b6c7174c
Parents: 0d72e03
Author: Mark McKenna <m4...@gmail.com>
Authored: Tue Mar 1 16:38:12 2016 +0000
Committer: Mark McKenna <m4...@gmail.com>
Committed: Tue Mar 1 16:40:41 2016 +0000

----------------------------------------------------------------------
 .../javascript/specs/model/application-spec.js  | 136 +++++++++----------
 src/test/javascript/specs/router-spec.js        |  60 ++++----
 .../specs/view/application-explorer-spec.js     |  16 +--
 3 files changed, 106 insertions(+), 106 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/ab9d62ca/src/test/javascript/specs/model/application-spec.js
----------------------------------------------------------------------
diff --git a/src/test/javascript/specs/model/application-spec.js b/src/test/javascript/specs/model/application-spec.js
index b03531d..dce9b06 100644
--- a/src/test/javascript/specs/model/application-spec.js
+++ b/src/test/javascript/specs/model/application-spec.js
@@ -24,105 +24,105 @@ define([
 
     describe('model/application Application model', function () {
 
-        var application = new Application.Model()
+        var application = new Application.Model();
 
-        application.url = 'fixtures/application.json'
-        application.fetch({async:false})
+        application.url = 'fixtures/application.json';
+        application.fetch({async:false});
 
         it('loads all model properties defined in fixtures/application.json', function () {
-            expect(application.get("status")).toEqual('STARTING')
-            expect(application.getLinkByName('self')).toEqual('/applications/myapp')
-            expect(application.getLinkByName('entities')).toEqual('fixtures/entity-summary-list.json')
-        })
+            expect(application.get("status")).toEqual('STARTING');
+            expect(application.getLinkByName('self')).toEqual('/applications/myapp');
+            expect(application.getLinkByName('entities')).toEqual('fixtures/entity-summary-list.json');
+        });
 
         it("loads the spec from fixtures/application.json", function () {
             var applicationSpec = application.getSpec(),
-                entity = new Entity.Model(applicationSpec.get("entities")[0])
+                entity = new Entity.Model(applicationSpec.get("entities")[0]);
 
-            expect(applicationSpec.get("name")).toEqual('myapp')
-            expect(applicationSpec.get("locations")[0]).toEqual('/locations/1')
-            expect(entity.get("name")).toEqual('Vanilla Java App')
-        })
+            expect(applicationSpec.get("name")).toEqual('myapp');
+            expect(applicationSpec.get("locations")[0]).toEqual('/locations/1');
+            expect(entity.get("name")).toEqual('Vanilla Java App');
+        });
 
         it('fetches entities from the spec url: fixtures/entity-summary-list.json', function () {
-            expect(application.getLinkByName('entities')).toBe('fixtures/entity-summary-list.json')
-        })
-    })
+            expect(application.getLinkByName('entities')).toBe('fixtures/entity-summary-list.json');
+        });
+    });
 
     describe('model/application', function () {
 
-        var spec, location, entity
+        var spec, location, entity;
 
         beforeEach(function () {
-            spec = new Application.Spec
-            location = "/locations/2"
-            entity = new Entity.Model({name:'test'})
+            spec = new Application.Spec;
+            location = "/locations/2";
+            entity = new Entity.Model({name:'test'});
 
-            spec.url = 'fixtures/application-spec.json'
-            spec.fetch({async:false})
-        })
+            spec.url = 'fixtures/application-spec.json';
+            spec.fetch({async:false});
+        });
 
         it('loads the properties from fixtures/application-spec.json', function () {
-            expect(spec.get("name")).toEqual('myapp')
-            expect(spec.get("locations")[0]).toEqual('/locations/1')
-            expect(spec.get("entities").length).toBe(1)
-        })
+            expect(spec.get("name")).toEqual('myapp');
+            expect(spec.get("locations")[0]).toEqual('/locations/1');
+            expect(spec.get("entities").length).toBe(1);
+        });
 
         it("loads the entity from fixtures/application-spec.json", function () {
-            var entity = new Entity.Model(spec.get("entities")[0])
-            expect(entity.get("name")).toEqual('Vanilla Java App')
-            expect(entity.get("type")).toEqual('org.apache.brooklyn.entity.java.VanillaJavaApp')
-            expect(entity.getConfigByName('initialSize')).toEqual('1')
-            expect(entity.getConfigByName('creationScriptUrl')).toEqual('http://my.brooklyn.io/storage/foo.sql')
-        })
+            var entity = new Entity.Model(spec.get("entities")[0]);
+            expect(entity.get("name")).toEqual('Vanilla Java App');
+            expect(entity.get("type")).toEqual('org.apache.brooklyn.entity.java.VanillaJavaApp');
+            expect(entity.getConfigByName('initialSize')).toEqual('1');
+            expect(entity.getConfigByName('creationScriptUrl')).toEqual('http://my.brooklyn.io/storage/foo.sql');
+        });
 
         it("triggers 'change' when we add a location", function () {
-            spyOn(spec, "trigger").andCallThrough()
-            spec.addLocation(location)
-            expect(spec.trigger).toHaveBeenCalled()
-            expect(spec.get("locations").length).toEqual(2)
-        })
+            spyOn(spec, "trigger").and.callThrough();
+            spec.addLocation(location);
+            expect(spec.trigger).toHaveBeenCalled();
+            expect(spec.get("locations").length).toEqual(2);
+        });
 
         it("triggers 'change' when we remove a location", function () {
-            spec.addLocation(location)
-            spyOn(spec, "trigger").andCallThrough()
+            spec.addLocation(location);
+            spyOn(spec, "trigger").and.callThrough();
 
-            spec.removeLocation('/invalid/location')
-            expect(spec.trigger).not.toHaveBeenCalled()
-            spec.removeLocation(location)
-            expect(spec.trigger).toHaveBeenCalled()
-            expect(spec.get("locations").length).toEqual(1)
-        })
+            spec.removeLocation('/invalid/location');
+            expect(spec.trigger).not.toHaveBeenCalled();
+            spec.removeLocation(location);
+            expect(spec.trigger).toHaveBeenCalled();
+            expect(spec.get("locations").length).toEqual(1);
+        });
 
         it('allows you to add the same location twice', function () {
             var spec = new Application.Spec,
-                location = '/ion/23'
-            spec.addLocation(location)
-            spec.addLocation(location)
-            expect(spec.get("locations").length).toEqual(2)
-        })
+                location = '/ion/23';
+            spec.addLocation(location);
+            spec.addLocation(location);
+            expect(spec.get("locations").length).toEqual(2);
+        });
 
         it("triggers 'change' when you add an entity", function () {
-            spyOn(spec, "trigger").andCallThrough()
-            spec.removeEntityByName(entity.get("name"))
-            expect(spec.trigger).not.toHaveBeenCalled()
-            spec.addEntity(entity)
-            expect(spec.trigger).toHaveBeenCalled()
-        })
+            spyOn(spec, "trigger").and.callThrough();
+            spec.removeEntityByName(entity.get("name"));
+            expect(spec.trigger).not.toHaveBeenCalled();
+            spec.addEntity(entity);
+            expect(spec.trigger).toHaveBeenCalled();
+        });
 
         it("triggers 'change' when you remove an entity", function () {
-            spec.addEntity(entity)
-            spyOn(spec, "trigger").andCallThrough()
-            spec.removeEntityByName(entity.get("name"))
-            expect(spec.trigger).toHaveBeenCalled()
-        })
+            spec.addEntity(entity);
+            spyOn(spec, "trigger").and.callThrough();
+            spec.removeEntityByName(entity.get("name"));
+            expect(spec.trigger).toHaveBeenCalled();
+        });
 
         it('allows you to add the same entity twice', function () {
             var spec = new Application.Spec,
-                entity = new Entity.Model({ name:'test-entity'})
-            spec.addEntity(entity)
-            spec.addEntity(entity)
-            expect(spec.get("entities").length).toEqual(2)
-        })
-    })
-})
+                entity = new Entity.Model({ name:'test-entity'});
+            spec.addEntity(entity);
+            spec.addEntity(entity);
+            expect(spec.get("entities").length).toEqual(2);
+        });
+    });
+});

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/ab9d62ca/src/test/javascript/specs/router-spec.js
----------------------------------------------------------------------
diff --git a/src/test/javascript/specs/router-spec.js b/src/test/javascript/specs/router-spec.js
index 8f54bb8..68311ef 100644
--- a/src/test/javascript/specs/router-spec.js
+++ b/src/test/javascript/specs/router-spec.js
@@ -22,41 +22,41 @@ define([
 
     var View = Backbone.View.extend({
         render:function () {
-            this.$el.html("<p>fake view</p>")
-            return this
+            this.$el.html("<p>fake view</p>");
+            return this;
         }
-    })
+    });
 
     describe("router", function () {
-        var view, router
+        var view, router;
 
         beforeEach(function () {
-            view = new View
-            router = new Router
-            $("body").append('<div id="container"></div>')
-        })
+            view = new View();
+            router = new Router();
+            $("body").append('<div id="container"></div>');
+        });
 
         afterEach(function () {
-            $("#container").remove()
-        })
+            $("#container").remove();
+        });
 
         it("shows the view inside div#container", function () {
-            expect($("body #container").length).toBe(1)
-            expect($("#container").text()).toBe("")
-            router.showView("#container", view)
-            expect($("#container").text()).toBe("fake view")
-        })
+            expect($("body #container").length).toBe(1);
+            expect($("#container").text()).toBe("");
+            router.showView("#container", view);
+            expect($("#container").text()).toBe("fake view");
+        });
 
         it("should call 'close' of old views", function () {
-            spyOn(view, "close")
+            spyOn(view, "close");
 
-            router.showView("#container", view)
-            expect(view.close).not.toHaveBeenCalled()
+            router.showView("#container", view);
+            expect(view.close).not.toHaveBeenCalled();
             // it should close the old view
-            router.showView("#container", new View)
-            expect(view.close).toHaveBeenCalled()
-        })
-    })
+            router.showView("#container", new View);
+            expect(view.close).toHaveBeenCalled();
+        });
+    });
 
     describe("Periodic functions", function() {
         var CallbackView = View.extend({
@@ -69,23 +69,23 @@ define([
         });
 
         // Expects callback to have been called at least once
-        it("should have 'this' set to the owning view", function() {
+        it("should have 'this' set to the owning view", function(done) {
             Brooklyn.view.refresh = true;
             var view = new CallbackView();
-            waits(15);
-            runs(function() {
+            setTimeout(function() {
                 expect(view.counter).toBeGreaterThan(0);
-            });
+                done();
+            },15);
         });
 
-        it("should not be run if Brooklyn.view.refresh is false", function() {
+        it("should not be run if Brooklyn.view.refresh is false", function(done) {
             Brooklyn.view.refresh = false;
             var view = new CallbackView();
-            waits(15);
-            runs(function() {
+            setTimeout(function() {
                 expect(view.counter).toEqual(0);
                 Brooklyn.view.refresh = true;
-            });
+                done();
+            },15);
         });
     });
 

http://git-wip-us.apache.org/repos/asf/brooklyn-ui/blob/ab9d62ca/src/test/javascript/specs/view/application-explorer-spec.js
----------------------------------------------------------------------
diff --git a/src/test/javascript/specs/view/application-explorer-spec.js b/src/test/javascript/specs/view/application-explorer-spec.js
index 3e3dd96..935d2dc 100644
--- a/src/test/javascript/specs/view/application-explorer-spec.js
+++ b/src/test/javascript/specs/view/application-explorer-spec.js
@@ -67,14 +67,14 @@ define([
                 expect(view.$("div#app-tree").length).toBe(1)
             })
 
-            it("triggers collection fetch on application refresh", function () {
-                spyOn(apps, "fetch").andCallThrough()
-                view.$(".application-tree-refresh").trigger("click")
-                waits(100)
-                runs(function () {
-                    expect(view.collection.fetch).toHaveBeenCalled()
-                })
-            })
+            it("triggers collection fetch on application refresh", function (done) {
+                spyOn(apps, "fetch").and.callThrough();
+                view.$(".application-tree-refresh").trigger("click");
+                setTimeout(function () {
+                    expect(view.collection.fetch).toHaveBeenCalled();
+                    done();
+                },100);
+            });
         })
     })
 })
\ No newline at end of file