describe("Tests for configuration store:", function() {
  var service, sandbox, contextFake;

  var radiatorConfigKey = "willow:custom_radiators";

  var testGraphConfig = {
    host: "test-host",
    instaceTag: "test-instances",
    metric: "test-metric"
  };

  var testGraphConfig2 = {
    host: "test-host2",
    instaceTag: "test-instances2",
    metric: "test-metric2"
  };

  var testGraphConfig3 = {
    host: "test-host3",
    instaceTag: "test-instances3",
    metric: "test-metric3"
  };

  var existingConfigurations = {
    rad1: [testGraphConfig2],
    rad2: [testGraphConfig2, testGraphConfig3]
  };

  beforeEach(function() {
    contextFake = new Box.TestServiceProvider();
    service = Box.Application.getServiceForTest('configuration-store', contextFake);
    sandbox = sinon.sandbox.create();
    var localStorageGetItemStubbed = sandbox.stub(window.localStorage, "getItem");
    localStorageGetItemStubbed.withArgs(radiatorConfigKey).returns(JSON.stringify(existingConfigurations));
  });

  it('lists available radiator names', function() {
    expect(service.customRadiators.listAvailableRadiators()).toEqual(['rad1','rad2']);
  });

  it('returns existing radiator configuration', function() {
    expect(service.customRadiators.readConfiguration("rad1")).toEqual([testGraphConfig2]);
  });

  it('append graph configuration in existing radiator config', function() {
    var expectedConfigurationsAfterAppend = {
      rad1: [testGraphConfig2, testGraphConfig],
      rad2: [testGraphConfig2, testGraphConfig3]
    };

    sandbox.stub(window.localStorage, "setItem")
      .withArgs(
        radiatorConfigKey,
        JSON.stringify(expectedConfigurationsAfterAppend)
      );

    service.customRadiators.appendConfiguration("rad1", testGraphConfig);
  });

  it('append graph configuration with new radiator key', function() {
    var expectedConfigurationsAfterAppend = {
      'rad1': [testGraphConfig2],
      'rad2': [testGraphConfig2, testGraphConfig3],
      'new-rad': [testGraphConfig]
    };

    sandbox.stub(window.localStorage, "setItem")
      .withArgs(
        radiatorConfigKey,
        JSON.stringify(expectedConfigurationsAfterAppend)
      );

    service.customRadiators.appendConfiguration("new-rad", testGraphConfig);
  });

  it('overwrite radiator configuration', function() {
    var expectedConfigurationsAfterAppend = {
      'rad1': [testGraphConfig2],
      'rad2': [testGraphConfig]
    };

    sandbox.stub(window.localStorage, "setItem")
      .withArgs(
        radiatorConfigKey,
        JSON.stringify(expectedConfigurationsAfterAppend)
      );

    service.customRadiators.storeConfiguration("rad2", [testGraphConfig]);
  });

  afterEach(function() {
    sandbox.verifyAndRestore();
  });
});
@@ -1530,33 +1530,32 @@
 Config3%5D%0A    %7D;%0A
-%0A
     sandbox.stub
@@ -1546,36 +1546,29 @@
     sandbox.
-stub(window.
+mock(
 localStorage
@@ -1563,35 +1563,43 @@
 localStorage
-, %22
+).expects('
 setItem
-%22
+'
 )%0A      .wit
@@ -1595,32 +1595,35 @@
 %0A      .with
+Exact
 Args(%0A
-  
       radiat
@@ -1627,34 +1627,32 @@
 iatorConfigKey,%0A
-  
       JSON.strin
@@ -1687,38 +1687,35 @@
 fterAppend)%0A    
-  
 );%0A
-%0A
     service.cust
@@ -2015,33 +2015,32 @@
 hConfig%5D%0A    %7D;%0A
-%0A
     sandbox.stub
@@ -2031,36 +2031,29 @@
     sandbox.
-stub(window.
+mock(
 localStorage
@@ -2052,35 +2052,43 @@
 lStorage
-, %22
+).expects('
 setItem
-%22
+'
 )%0A      
 .withArg
@@ -2075,37 +2075,42 @@
 tem')%0A      
+  
 .with
+Exact
 Args(%0A
-  
       radiat
@@ -2114,34 +2114,32 @@
 iatorConfigKey,%0A
-  
       JSON.strin
@@ -2174,38 +2174,35 @@
 fterAppend)%0A    
-  
 );%0A
-%0A
     service.cust
@@ -2442,17 +2442,16 @@
 %0A    %7D;%0A
-%0A
     sand
@@ -2450,36 +2450,29 @@
     sandbox.
-stub(window.
+mock(
 localStorage
@@ -2475,27 +2475,35 @@
 rage
-, %22
+).expects('
 setItem
-%22
+'
 )%0A      
 .wit
@@ -2502,21 +2502,26 @@
     
+  
 .with
+Exact
 Args(%0A
-  
     
@@ -2537,26 +2537,24 @@
 rConfigKey,%0A
-  
       JSON.s
@@ -2605,14 +2605,11 @@
     
-  
 );%0A
-%0A
     

Revert "fixed localStorage stubbing for setItem"