import sessionsReducer from '../../app/reducers/sessions'
import actions from '../../app/actions/sessions'
import expect from 'expect';

describe("The sessions reducer", () => {
  const initialState = {
    data: {}
  }

  const stateWithData = {
    data: {
      "session1": {foo: "bar"}
    }
  }

  it("can update a session", () => {
    const action = actions.update("session1", {foo: "bar"});
    const newState = sessionsReducer(initialState, action);
    expect(newState).toNotEqual(initialState);
  })

  it("can update a session by using the session key", () => {
    const action = actions.update("session1", {foo: "bar"});
    const newState = sessionsReducer(initialState, action);
    const expected = stateWithData;
    expect(newState).toEqual(expected);
  })

  it('can delete a session by using the session key', () => {
    const action = actions.delete("session1")
    const currentState = stateWithData;
    const newState = sessionsReducer(currentState, action)
    const expected = {
      data: {
      }
    }
    expect(newState).toEqual(expected)
  })

  it('can delete all session data with delete all', ()=>{
    const action = actions.deleteAll();
    const currentState = stateWithData;
    const newState = sessionsReducer(currentState, action)
    const expected = {
      data: {
      }
    }
    expect(newState).toEqual(expected);
  })
})

@@ -1,12 +1,15 @@
+// 
 import sessi
@@ -50,24 +50,27 @@
 s/sessions'%0A
+// 
 import actio
@@ -106,16 +106,19 @@
 ssions'%0A
+// 
 import e
@@ -138,17 +138,22 @@
 xpect';%0A
-%0A
+//%0A// 
 describe
@@ -185,16 +185,19 @@
 () =%3E %7B%0A
+// 
   const 
@@ -209,24 +209,27 @@
 alState = %7B%0A
+// 
     data: %7B%7D
@@ -229,23 +229,31 @@
 ata: %7B%7D%0A
+// 
   %7D%0A
-%0A
+//%0A//
   
+ 
 const st
@@ -264,24 +264,27 @@
 ithData = %7B%0A
+// 
     data: %7B%0A
@@ -279,24 +279,27 @@
     data: %7B%0A
+// 
       %22sessi
@@ -321,19 +321,30 @@
 r%22%7D%0A
+//
     
+ 
 %7D%0A
+//
   
+ 
 %7D%0A
-%0A
+//%0A// 
   it
@@ -368,32 +368,35 @@
 ssion%22, () =%3E %7B%0A
+// 
     const action
@@ -432,36 +432,39 @@
  %7Bfoo: %22bar%22%7D);%0A
+//
     
+ 
 const newState =
@@ -499,24 +499,27 @@
 e, action);%0A
+// 
     expect(n
@@ -553,22 +553,30 @@
 State);%0A
+// 
   %7D)%0A
-%0A
+//%0A// 
   it(%22ca
@@ -621,32 +621,35 @@
 n key%22, () =%3E %7B%0A
+// 
     const action
@@ -693,16 +693,19 @@
 bar%22%7D);%0A
+// 
     cons
@@ -756,16 +756,19 @@
 ction);%0A
+// 
     cons
@@ -791,24 +791,27 @@
 teWithData;%0A
+// 
     expect(n
@@ -838,24 +838,32 @@
 ected);%0A
+// 
   %7D)%0A
-%0A
+//%0A//
   
+ 
 it('can 
@@ -914,16 +914,19 @@
 () =%3E %7B%0A
+// 
     cons
@@ -963,16 +963,19 @@
 sion1%22)%0A
+// 
     cons
@@ -998,36 +998,39 @@
  stateWithData;%0A
+//
     
+ 
 const newState =
@@ -1060,32 +1060,35 @@
 tState, action)%0A
+// 
     const expect
@@ -1086,32 +1086,35 @@
 st expected = %7B%0A
+// 
       data: %7B%0A  
@@ -1107,38 +1107,47 @@
     data: %7B%0A
+//
       
+ 
 %7D%0A
+// 
     %7D%0A
+// 
     expect(n
@@ -1177,14 +1177,22 @@
 ed)%0A
+//
   
+ 
 %7D)%0A
-%0A
+//%0A// 
   it
@@ -1245,16 +1245,19 @@
 , ()=%3E%7B%0A
+// 
     cons
@@ -1288,16 +1288,19 @@
 eAll();%0A
+// 
     cons
@@ -1331,16 +1331,19 @@
 thData;%0A
+// 
     cons
@@ -1393,16 +1393,19 @@
 action)%0A
+// 
     cons
@@ -1419,16 +1419,19 @@
 ted = %7B%0A
+// 
       da
@@ -1440,22 +1440,31 @@
 : %7B%0A
+//
       
+ 
 %7D%0A
+// 
     %7D%0A
+// 
     
@@ -1499,16 +1499,22 @@
 ected);%0A
+// 
   %7D)%0A
+// 
 %7D)%0A

Remove outdated sessions tests