1 describe("app.services.ClusterState", function() {
3 var ClusterState = window.app.services.ClusterState;
4 var test = window.test;
10 function expectAllDataToBeNull() {
11 expect( c.clusterState ).toBe( null );
12 expect( c.status ).toBe( null );
13 expect( c.nodeStats ).toBe( null );
14 expect( c.clusterNodes ).toBe( null );
17 beforeEach( function() {
19 dataEventCallback = jasmine.createSpy("onData");
20 c = new ClusterState({
22 get: test.cb.createSpy("get", 1, [ dummyData ] )
24 onData: dataEventCallback
28 describe( "when it is initialised", function() {
30 it("should have null data", function() {
31 expectAllDataToBeNull();
36 describe( "when refresh is called", function() {
38 beforeEach( function() {
42 it("should not not update models until all network requests have completed", function() {
44 expectAllDataToBeNull();
46 expectAllDataToBeNull();
48 expectAllDataToBeNull();
50 expectAllDataToBeNull();
52 expect( c.clusterState ).toBe( dummyData );
53 expect( c.status ).toBe( dummyData );
54 expect( c.nodeStats ).toBe( dummyData );
55 expect( c.clusterNodes ).toBe( dummyData );
58 it("should fire a 'data' event when all data is ready", function() {
60 expect( dataEventCallback ).toHaveBeenCalledWith( c );