8b8be82d7633dc92a522cab2bdcb64141b3c1c8c
[ccsdk/features.git] /
1 describe("clusterConnect", function() {
2
3         var ClusterConnect = window.app.ui.ClusterConnect;
4
5         describe("when created", function() {
6
7                 var prefs, success_callback, cluster, clusterConnect;
8
9                 beforeEach( function() {
10                         prefs = {
11                                 set: jasmine.createSpy("set")
12                         };
13                         spyOn( window.app.services.Preferences, "instance" ).and.callFake( function() {
14                                 return prefs;
15                         });
16                         cluster = {
17                                 get: jasmine.createSpy("get").and.callFake( function(uri, success) {
18                                         success_callback = success;
19                                 })
20                         };
21                         clusterConnect = new ClusterConnect({
22                                 base_uri: "http://localhost:9200",
23                                 cluster: cluster
24                         });
25                 });
26
27                 it("should test the connection to the cluster", function() {
28                         expect( cluster.get ).toHaveBeenCalled();
29                 });
30
31                 it("should store successful connection in preferences", function() {
32                         success_callback("fakePayload");
33                         expect( prefs.set ).toHaveBeenCalled();
34                 });
35
36         });
37
38 });