Skip to content

Commit

Permalink
Merge pull request #79 from fga-gpp-mds/devel
Browse files Browse the repository at this point in the history
TS08 - Transferir usuário para Nuvem Cívica
  • Loading branch information
Rdlenke authored Oct 27, 2017
2 parents fc73b50 + 61b98de commit f4e3516
Show file tree
Hide file tree
Showing 45 changed files with 1,464 additions and 1,061 deletions.
3 changes: 2 additions & 1 deletion App.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@ import store from './src/Reducers/store';
/*
Change loggersLevel value to control loggers visualization.
loggersLevel = 'all' -> All loggers activate
loggersLevel = 'all -trace' -> All loggers activate execept trace loggers
loggersLevel = 'trace' -> Only trace loggers activate
loggersLevel = 'info' -> Only info loggers activate
loggersLevel = 'warn' -> Only warn loggers activate
loggersLevel = 'error' -> Only error loggers activate
loggersLevel = 'none' -> All loggers deactive
*/
export const loggersLevel = 'all';
export const loggersLevel = 'all -trace';

const App = () => ({
render() {
Expand Down
86 changes: 86 additions & 0 deletions __tests__/Reducers/applicationReducer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
import applicationReducer from '../../src/Reducers/applicationReducer';
import initialState from '../../src/Reducers/initialState';
import { IS_LOADING, IS_NOT_LOADING } from '../../src/actions/types';

describe('Testing applicationReducer', () => {
it('Is Loading', () => {
let application = initialState.application;

expect(application.isLoading).toBe(false);
expect(application.message_erro).toBe('');

const sendedApplication = {
isLoading: true,
message_erro: '',
};

const action = {
type: IS_LOADING,
payload: sendedApplication,
};

application = applicationReducer(application, action);

expect(application).toEqual(sendedApplication);
});

it('Is not Loading', () => {
let application = {
...initialState.application,
isLoading: true,
};

expect(application.isLoading).toBe(true);
expect(application.message_erro).toBe('');

const sendedApplication = {
isLoading: false,
message_erro: '',
};

const action = {
type: IS_NOT_LOADING,
payload: sendedApplication,
};

application = applicationReducer(application, action);

expect(application).toEqual(sendedApplication);
});


it('Default action type', () => {
let application = initialState.application;

expect(application.isLoading).toBe(false);
expect(application.message_erro).toBe('');

const sendedApplication = application;

const action = {
type: 'DEFAULT_TYPE_TO_ACTION',
payload: 'DEFAULT_VALUE_TO_ACTION',
};

application = applicationReducer(application, action);

expect(application).toEqual(sendedApplication);
});

it('Undefined action sended', () => {
let application = initialState.application;

expect(application.isLoading).toBe(false);
expect(application.message_erro).toBe('');

const sendedApplication = application;

const action = undefined;

expect(action).toBeUndefined();

application = applicationReducer(application, action);

expect(application).toEqual(sendedApplication);
});
});
101 changes: 0 additions & 101 deletions __tests__/Reducers/counselorReducer-test.js

This file was deleted.

192 changes: 192 additions & 0 deletions __tests__/Reducers/counselorReducer.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,192 @@
import counselorReducer from '../../src/Reducers/counselorReducer';
import initialState from '../../src/Reducers/initialState';
import { SET_COUNSELOR, SET_TOKEN, SET_COUNSELOR_EDITED } from '../../src/actions/types';

describe('Testing counselorReducer', () => {
it('Sets counselor', () => {
let counselor = initialState.counselor;

expect(counselor.nuvemCode).toBe(0);
expect(counselor.email).toBe('');
expect(counselor.name).toBe('');
expect(counselor.userName).toBe('');
expect(counselor.password).toBe('');
expect(counselor.token).toBe('');
expect(counselor.profile.cpf).toBe('');
expect(counselor.profile.phone).toBe('');
expect(counselor.profile.isPresident).toBe(false);
expect(counselor.profile.segment).toBe('');
expect(counselor.profile.CAE_Type).toBe('');
expect(counselor.profile.CAE).toBe('');

const sendedCounselor = {
nuvemCode: 1,
email: '[email protected]',
name: 'Rodolfo',
userName: '[email protected]',
password: 'senha',
token: 'tokenGenerico',
profile: {
cpf: '12312312312',
phone: '96661234',
isPresident: false,
segment: 'Titular',
CAE_Type: 'Estadual',
CAE: 'Distrito Federal',
},
};

const action = {
type: SET_COUNSELOR,
payload: sendedCounselor,
};

counselor = counselorReducer(counselor, action);

expect(counselor).toEqual(sendedCounselor);
});

it('Sets counselor token', () => {
let counselor = initialState.counselor;

expect(counselor.nuvemCode).toBe(0);
expect(counselor.email).toBe('');
expect(counselor.name).toBe('');
expect(counselor.userName).toBe('');
expect(counselor.password).toBe('');
expect(counselor.token).toBe('');
expect(counselor.profile.cpf).toBe('');
expect(counselor.profile.phone).toBe('');
expect(counselor.profile.isPresident).toBe(false);
expect(counselor.profile.segment).toBe('');
expect(counselor.profile.CAE_Type).toBe('');
expect(counselor.profile.CAE).toBe('');

const sendedCounselor = {
nuvemCode: 0,
email: '',
name: '',
userName: '',
password: '',
token: 'tokenGenerico',
profile: {
cpf: '',
phone: '',
isPresident: false,
segment: '',
CAE_Type: '',
CAE: '',
},
};

const action = {
type: SET_TOKEN,
payload: sendedCounselor.token,
};

counselor = counselorReducer(counselor, action);

expect(counselor).toEqual(sendedCounselor);
});

it('Sets counselor edited', () => {
let counselor = initialState.counselor;

expect(counselor.nuvemCode).toBe(0);
expect(counselor.email).toBe('');
expect(counselor.name).toBe('');
expect(counselor.userName).toBe('');
expect(counselor.password).toBe('');
expect(counselor.token).toBe('');
expect(counselor.profile.cpf).toBe('');
expect(counselor.profile.phone).toBe('');
expect(counselor.profile.isPresident).toBe(false);
expect(counselor.profile.segment).toBe('');
expect(counselor.profile.CAE_Type).toBe('');
expect(counselor.profile.CAE).toBe('');

const sendedCounselor = {
nuvemCode: 0,
email: '',
name: 'Romario',
userName: '',
password: '',
token: '',
profile: {
cpf: '12312312312',
phone: '987654321',
isPresident: true,
segment: 'Suplente',
CAE_Type: 'Municipal',
CAE: 'Porto Velho',
},
};

const action = {
type: SET_COUNSELOR_EDITED,
payload: {
name: sendedCounselor.name,
profile: sendedCounselor.profile,
},
};

counselor = counselorReducer(counselor, action);

expect(counselor).toEqual(sendedCounselor);
});

it('Default action type', () => {
let counselor = initialState.counselor;

expect(counselor.nuvemCode).toBe(0);
expect(counselor.email).toBe('');
expect(counselor.name).toBe('');
expect(counselor.userName).toBe('');
expect(counselor.password).toBe('');
expect(counselor.token).toBe('');
expect(counselor.profile.cpf).toBe('');
expect(counselor.profile.phone).toBe('');
expect(counselor.profile.isPresident).toBe(false);
expect(counselor.profile.segment).toBe('');
expect(counselor.profile.CAE_Type).toBe('');
expect(counselor.profile.CAE).toBe('');

const sendedCounselor = counselor;

const action = {
type: 'DEFAULT_TYPE_TO_ACTION',
payload: 'DEFAULT_VALUE_TO_ACTION',
};

counselor = counselorReducer(counselor, action);

expect(counselor).toEqual(sendedCounselor);
});

it('Undefined action sended', () => {
let counselor = initialState.counselor;

expect(counselor.nuvemCode).toBe(0);
expect(counselor.email).toBe('');
expect(counselor.name).toBe('');
expect(counselor.userName).toBe('');
expect(counselor.password).toBe('');
expect(counselor.token).toBe('');
expect(counselor.profile.cpf).toBe('');
expect(counselor.profile.phone).toBe('');
expect(counselor.profile.isPresident).toBe(false);
expect(counselor.profile.segment).toBe('');
expect(counselor.profile.CAE_Type).toBe('');
expect(counselor.profile.CAE).toBe('');

const sendedCounselor = counselor;

const action = undefined;

expect(action).toBeUndefined();

counselor = counselorReducer(counselor, action);

expect(counselor).toEqual(sendedCounselor);
});
});
Loading

0 comments on commit f4e3516

Please sign in to comment.