|  | 
| 1 | 1 | import expect from 'expect'; | 
| 2 | 2 | import { combineReducers } from '../../src'; | 
| 3 |  | -import { ActionTypes } from '../../src/createStore'; | 
|  | 3 | +import createStore, { ActionTypes } from '../../src/createStore'; | 
| 4 | 4 | 
 | 
| 5 | 5 | describe('Utils', () => { | 
| 6 | 6 |   describe('combineReducers', () => { | 
| @@ -130,61 +130,55 @@ describe('Utils', () => { | 
| 130 | 130 |       spy.restore(); | 
| 131 | 131 |     }); | 
| 132 | 132 | 
 | 
| 133 |  | -    it('should warn if initial state object does not match state object returned by reducer', () => { | 
|  | 133 | +    it('should warn if input state object does not match state object returned by reducer', () => { | 
| 134 | 134 |       const spy = expect.spyOn(console, 'error'); | 
| 135 |  | -      const reducerCreator = () => { | 
| 136 |  | -        return combineReducers({ | 
| 137 |  | -          foo(state = {bar: 1}) { | 
| 138 |  | -            return state; | 
| 139 |  | -          }, | 
| 140 |  | -          baz(state = {qux: 3}) { | 
| 141 |  | -            return state; | 
| 142 |  | -          } | 
| 143 |  | -        }); | 
| 144 |  | -      }; | 
|  | 135 | +      const reducer = combineReducers({ | 
|  | 136 | +        foo(state = {bar: 1}) { | 
|  | 137 | +          return state; | 
|  | 138 | +        }, | 
|  | 139 | +        baz(state = {qux: 3}) { | 
|  | 140 | +          return state; | 
|  | 141 | +        } | 
|  | 142 | +      }); | 
| 145 | 143 | 
 | 
| 146 |  | -      reducerCreator()({foo: {bar: 2}}); | 
|  | 144 | +      reducer({foo: {bar: 2}}); | 
| 147 | 145 |       expect(spy.calls.length).toBe(0); | 
| 148 | 146 | 
 | 
| 149 |  | -      reducerCreator()({ | 
|  | 147 | +      reducer({ | 
| 150 | 148 |         foo: {bar: 2}, | 
| 151 | 149 |         baz: {qux: 4} | 
| 152 | 150 |       }); | 
| 153 | 151 |       expect(spy.calls.length).toBe(0); | 
| 154 | 152 | 
 | 
| 155 |  | -      reducerCreator()({bar: 2}); | 
|  | 153 | +      createStore(reducer, {bar: 2}); | 
| 156 | 154 |       expect(spy.calls[0].arguments[0]).toMatch( | 
| 157 |  | -        /Unexpected key "bar".*instead: "foo", "baz"/ | 
|  | 155 | +        /Unexpected key "bar".*createStore.*instead: "foo", "baz"/ | 
| 158 | 156 |       ); | 
| 159 | 157 | 
 | 
| 160 |  | -      reducerCreator()({bar: 2, qux: 4}); | 
|  | 158 | +      createStore(reducer, {bar: 2, qux: 4}); | 
| 161 | 159 |       expect(spy.calls[1].arguments[0]).toMatch( | 
| 162 |  | -        /Unexpected keys "bar", "qux".*instead: "foo", "baz"/ | 
|  | 160 | +        /Unexpected keys "bar", "qux".*createStore.*instead: "foo", "baz"/ | 
| 163 | 161 |       ); | 
| 164 | 162 | 
 | 
| 165 |  | -      reducerCreator()(1); | 
|  | 163 | +      createStore(reducer, 1); | 
| 166 | 164 |       expect(spy.calls[2].arguments[0]).toMatch( | 
| 167 |  | -        /unexpected type of "Number".*keys: "foo", "baz"/ | 
|  | 165 | +        /createStore has unexpected type of "Number".*keys: "foo", "baz"/ | 
| 168 | 166 |       ); | 
| 169 | 167 | 
 | 
| 170 |  | -      spy.restore(); | 
| 171 |  | -    }); | 
| 172 |  | - | 
| 173 |  | -    it('should only check state shape on init', () => { | 
| 174 |  | -      const spy = expect.spyOn(console, 'error'); | 
| 175 |  | -      const reducer = combineReducers({ | 
| 176 |  | -        foo(state = {bar: 1}) { | 
| 177 |  | -          return state; | 
| 178 |  | -        } | 
| 179 |  | -      }); | 
|  | 168 | +      reducer({bar: 2}); | 
|  | 169 | +      expect(spy.calls[3].arguments[0]).toMatch( | 
|  | 170 | +        /Unexpected key "bar".*reducer.*instead: "foo", "baz"/ | 
|  | 171 | +      ); | 
| 180 | 172 | 
 | 
| 181 |  | -      reducer({bar: 1}); | 
| 182 |  | -      expect(spy.calls[0].arguments[0]).toMatch( | 
| 183 |  | -        /Unexpected key "bar".*instead: "foo"/ | 
|  | 173 | +      reducer({bar: 2, qux: 4}); | 
|  | 174 | +      expect(spy.calls[4].arguments[0]).toMatch( | 
|  | 175 | +        /Unexpected keys "bar", "qux".*reducer.*instead: "foo", "baz"/ | 
| 184 | 176 |       ); | 
| 185 | 177 | 
 | 
| 186 |  | -      reducer({bar: 1}); | 
| 187 |  | -      expect(spy.calls.length).toBe(1); | 
|  | 178 | +      reducer(1); | 
|  | 179 | +      expect(spy.calls[5].arguments[0]).toMatch( | 
|  | 180 | +        /reducer has unexpected type of "Number".*keys: "foo", "baz"/ | 
|  | 181 | +      ); | 
| 188 | 182 | 
 | 
| 189 | 183 |       spy.restore(); | 
| 190 | 184 |     }); | 
|  | 
0 commit comments