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 { Action } from 'redux';
import { IBanner } from '../reducers/encryption';
import { ENCRYPTION } from './actionsTypes'; import { ENCRYPTION } from './actionsTypes';
export interface IEncryptionSet extends Action { export interface IEncryptionSet extends Action {
enabled: boolean; enabled: boolean;
banner: any; banner: IBanner;
} }
export interface IEncryptionSetBanner extends Action { export interface IEncryptionSetBanner extends Action {
banner: any; banner: IBanner;
} }
export interface IEncryptionDecodeKey extends Action { export interface IEncryptionDecodeKey extends Action {
password: string; 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 { return {
type: ENCRYPTION.SET, type: ENCRYPTION.SET,
enabled, 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 { return {
type: ENCRYPTION.SET_BANNER, type: ENCRYPTION.SET_BANNER,
banner banner

View File

@ -9,20 +9,20 @@ describe('test encryption reducer', () => {
}); });
it('should return modified store after encryptionSet', () => { it('should return modified store after encryptionSet', () => {
mockedStore.dispatch(encryptionSet(true, true)); mockedStore.dispatch(encryptionSet(true, 'BANNER'));
const state = mockedStore.getState().encryption; 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', () => { it('should return empty store after encryptionInit', () => {
mockedStore.dispatch(encryptionInit()); mockedStore.dispatch(encryptionInit());
const state = mockedStore.getState().encryption; 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', () => { it('should return initial state after encryptionSetBanner', () => {
mockedStore.dispatch(encryptionSetBanner(true)); mockedStore.dispatch(encryptionSetBanner('BANNER_NEW'));
const state = mockedStore.getState().encryption; 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 { ENCRYPTION } from '../actions/actionsTypes';
import { TApplicationActions } from '../definitions'; import { TApplicationActions } from '../definitions';
export type IBanner = string;
export interface IEncryption { export interface IEncryption {
enabled: boolean; enabled: boolean;
// TODO banner: IBanner;
banner: any;
} }
export const initialState: IEncryption = { export const initialState: IEncryption = {
enabled: false, enabled: false,
banner: null banner: ''
}; };
export default function encryption(state = initialState, action: TApplicationActions): IEncryption { export default function encryption(state = initialState, action: TApplicationActions): IEncryption {