2018-02-12 20:43:07 +00:00
|
|
|
import { meta } from 'reducers/config/meta';
|
2018-04-11 02:53:27 +00:00
|
|
|
import {
|
|
|
|
changeLanguage,
|
|
|
|
setOnline,
|
|
|
|
setOffline,
|
|
|
|
toggleAutoGasLimit,
|
|
|
|
setLatestBlock
|
|
|
|
} from 'actions/config';
|
2018-02-12 20:43:07 +00:00
|
|
|
|
|
|
|
const expectedInitialState = {
|
|
|
|
languageSelection: 'en',
|
|
|
|
offline: false,
|
|
|
|
autoGasLimit: true,
|
|
|
|
latestBlock: '???'
|
|
|
|
};
|
|
|
|
|
|
|
|
const expectedState = {
|
|
|
|
initialState: expectedInitialState,
|
|
|
|
changingLanguage: {
|
|
|
|
...expectedInitialState,
|
|
|
|
languageSelection: 'langaugeToChange'
|
|
|
|
},
|
|
|
|
togglingToOffline: {
|
|
|
|
...expectedInitialState,
|
|
|
|
offline: true
|
|
|
|
},
|
|
|
|
togglingToOnline: {
|
|
|
|
...expectedInitialState,
|
|
|
|
offline: false
|
|
|
|
},
|
|
|
|
togglingToManualGasLimit: {
|
|
|
|
...expectedInitialState,
|
|
|
|
autoGasLimit: false
|
|
|
|
},
|
|
|
|
togglingToAutoGasLimit: {
|
|
|
|
...expectedInitialState,
|
|
|
|
autoGasLimit: true
|
|
|
|
},
|
|
|
|
settingLatestBlock: {
|
|
|
|
...expectedInitialState,
|
|
|
|
latestBlock: '12345'
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
const actions = {
|
|
|
|
changeLangauge: changeLanguage('langaugeToChange'),
|
2018-04-11 02:53:27 +00:00
|
|
|
setOnline: setOnline(),
|
|
|
|
setOffline: setOffline(),
|
2018-02-12 20:43:07 +00:00
|
|
|
toggleAutoGasLimit: toggleAutoGasLimit(),
|
|
|
|
setLatestBlock: setLatestBlock('12345')
|
|
|
|
};
|
|
|
|
|
|
|
|
describe('meta reducer', () => {
|
|
|
|
it('should return the inital state', () =>
|
|
|
|
expect(meta(undefined, {} as any)).toEqual(expectedState.initialState));
|
|
|
|
|
|
|
|
it('should handle toggling to offline', () =>
|
2018-04-11 02:53:27 +00:00
|
|
|
expect(meta(expectedState.initialState, actions.setOffline)).toEqual(
|
2018-02-12 20:43:07 +00:00
|
|
|
expectedState.togglingToOffline
|
|
|
|
));
|
|
|
|
|
|
|
|
it('should handle toggling back to online', () =>
|
2018-04-11 02:53:27 +00:00
|
|
|
expect(meta(expectedState.togglingToOffline, actions.setOnline)).toEqual(
|
2018-02-12 20:43:07 +00:00
|
|
|
expectedState.togglingToOnline
|
|
|
|
));
|
|
|
|
|
|
|
|
it('should handle toggling to manual gas limit', () =>
|
|
|
|
expect(meta(expectedState.initialState, actions.toggleAutoGasLimit)).toEqual(
|
|
|
|
expectedState.togglingToManualGasLimit
|
|
|
|
));
|
|
|
|
|
|
|
|
it('should handle toggling back to auto gas limit', () =>
|
|
|
|
expect(meta(expectedState.togglingToManualGasLimit, actions.toggleAutoGasLimit)).toEqual(
|
|
|
|
expectedState.togglingToAutoGasLimit
|
|
|
|
));
|
|
|
|
|
|
|
|
it('should handle setting the latest block', () =>
|
|
|
|
expect(meta(expectedState.initialState, actions.setLatestBlock)).toEqual(
|
|
|
|
expectedState.settingLatestBlock
|
|
|
|
));
|
|
|
|
});
|
|
|
|
|
|
|
|
export { actions as metaActions, expectedState as metaExpectedState };
|