mirror of
https://github.com/shlinkio/shlink-web-client.git
synced 2024-12-23 01:20:24 +03:00
Migrated appUpdated reducer to RTK
This commit is contained in:
parent
26c3ea19f4
commit
85e2aab4df
3 changed files with 17 additions and 24 deletions
|
@ -1,16 +1,14 @@
|
|||
import { Action } from 'redux';
|
||||
import { buildActionCreator, buildReducer } from '../../utils/helpers/redux';
|
||||
import { createSlice } from '@reduxjs/toolkit';
|
||||
|
||||
export const APP_UPDATE_AVAILABLE = 'shlink/appUpdates/APP_UPDATE_AVAILABLE';
|
||||
export const RESET_APP_UPDATE = 'shlink/appUpdates/RESET_APP_UPDATE';
|
||||
const { actions, reducer } = createSlice({
|
||||
name: 'appUpdatesReducer',
|
||||
initialState: false,
|
||||
reducers: {
|
||||
appUpdateAvailable: () => true,
|
||||
resetAppUpdate: () => false,
|
||||
},
|
||||
});
|
||||
|
||||
const initialState = false;
|
||||
export const { appUpdateAvailable, resetAppUpdate } = actions;
|
||||
|
||||
export default buildReducer<boolean, Action<string>>({
|
||||
[APP_UPDATE_AVAILABLE]: () => true,
|
||||
[RESET_APP_UPDATE]: () => false,
|
||||
}, initialState);
|
||||
|
||||
export const appUpdateAvailable = buildActionCreator(APP_UPDATE_AVAILABLE);
|
||||
|
||||
export const resetAppUpdate = buildActionCreator(RESET_APP_UPDATE);
|
||||
export const appUpdatesReducer = reducer;
|
||||
|
|
|
@ -18,7 +18,7 @@ import tagEditReducer from '../tags/reducers/tagEdit';
|
|||
import mercureInfoReducer from '../mercure/reducers/mercureInfo';
|
||||
import settingsReducer from '../settings/reducers/settings';
|
||||
import visitsOverviewReducer from '../visits/reducers/visitsOverview';
|
||||
import appUpdatesReducer from '../app/reducers/appUpdates';
|
||||
import { appUpdatesReducer } from '../app/reducers/appUpdates';
|
||||
import sidebarReducer from '../common/reducers/sidebar';
|
||||
import { ShlinkState } from '../container/types';
|
||||
|
||||
|
|
|
@ -1,30 +1,25 @@
|
|||
import reducer, {
|
||||
APP_UPDATE_AVAILABLE,
|
||||
RESET_APP_UPDATE,
|
||||
appUpdateAvailable,
|
||||
resetAppUpdate,
|
||||
} from '../../../src/app/reducers/appUpdates';
|
||||
import { appUpdatesReducer, appUpdateAvailable, resetAppUpdate } from '../../../src/app/reducers/appUpdates';
|
||||
|
||||
describe('appUpdatesReducer', () => {
|
||||
describe('reducer', () => {
|
||||
it('returns true on APP_UPDATE_AVAILABLE', () => {
|
||||
expect(reducer(undefined, { type: APP_UPDATE_AVAILABLE })).toEqual(true);
|
||||
expect(appUpdatesReducer(undefined, { type: appUpdateAvailable.toString() })).toEqual(true);
|
||||
});
|
||||
|
||||
it('returns false on RESET_APP_UPDATE', () => {
|
||||
expect(reducer(undefined, { type: RESET_APP_UPDATE })).toEqual(false);
|
||||
expect(appUpdatesReducer(undefined, { type: resetAppUpdate.toString() })).toEqual(false);
|
||||
});
|
||||
});
|
||||
|
||||
describe('appUpdateAvailable', () => {
|
||||
it('creates expected action', () => {
|
||||
expect(appUpdateAvailable()).toEqual({ type: APP_UPDATE_AVAILABLE });
|
||||
expect(appUpdateAvailable()).toEqual({ type: appUpdateAvailable.toString() });
|
||||
});
|
||||
});
|
||||
|
||||
describe('resetAppUpdate', () => {
|
||||
it('creates expected action', () => {
|
||||
expect(resetAppUpdate()).toEqual({ type: RESET_APP_UPDATE });
|
||||
expect(resetAppUpdate()).toEqual({ type: resetAppUpdate.toString() });
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue