chore: fix any interface and change null to empty string

This commit is contained in:
GleidsonDaniel 2022-01-18 09:49:44 -03:00
parent 49ac4c1f65
commit 953de7f521
3 changed files with 13 additions and 12 deletions

View File

@ -1,14 +1,15 @@
import { Action } from 'redux';
import { IBanner } from '../reducers/encryption';
import { ENCRYPTION } from './actionsTypes';
export interface IEncryptionSet extends Action {
enabled: boolean;
banner: any;
banner: IBanner;
}
export interface IEncryptionSetBanner extends Action {
banner: any;
banner: IBanner;
}
export interface IEncryptionDecodeKey extends Action {
password: string;
@ -28,7 +29,7 @@ export function encryptionStop(): Action {
};
}
export function encryptionSet(enabled = false, banner: any = null): IEncryptionSet {
export function encryptionSet(enabled = false, banner: IBanner = ''): IEncryptionSet {
return {
type: ENCRYPTION.SET,
enabled,
@ -36,7 +37,7 @@ export function encryptionSet(enabled = false, banner: any = null): IEncryptionS
};
}
export function encryptionSetBanner(banner: any = null): IEncryptionSetBanner {
export function encryptionSetBanner(banner: IBanner = ''): IEncryptionSetBanner {
return {
type: ENCRYPTION.SET_BANNER,
banner

View File

@ -9,20 +9,20 @@ describe('test encryption reducer', () => {
});
it('should return modified store after encryptionSet', () => {
mockedStore.dispatch(encryptionSet(true, true));
mockedStore.dispatch(encryptionSet(true, 'BANNER'));
const state = mockedStore.getState().encryption;
expect(state).toEqual({ banner: true, enabled: true });
expect(state).toEqual({ banner: 'BANNER', enabled: true });
});
it('should return empty store after encryptionInit', () => {
mockedStore.dispatch(encryptionInit());
const state = mockedStore.getState().encryption;
expect(state).toEqual({ banner: null, enabled: false });
expect(state).toEqual({ banner: '', enabled: false });
});
it('should return initial state after encryptionSetBanner', () => {
mockedStore.dispatch(encryptionSetBanner(true));
mockedStore.dispatch(encryptionSetBanner('BANNER_NEW'));
const state = mockedStore.getState().encryption;
expect(state).toEqual({ banner: true, enabled: false });
expect(state).toEqual({ banner: 'BANNER_NEW', enabled: false });
});
});

View File

@ -1,15 +1,15 @@
import { ENCRYPTION } from '../actions/actionsTypes';
import { TApplicationActions } from '../definitions';
export type IBanner = string;
export interface IEncryption {
enabled: boolean;
// TODO
banner: any;
banner: IBanner;
}
export const initialState: IEncryption = {
enabled: false,
banner: null
banner: ''
};
export default function encryption(state = initialState, action: TApplicationActions): IEncryption {