Skip to content

Commit

Permalink
Envio do projeto com arquitetura base
Browse files Browse the repository at this point in the history
  • Loading branch information
eduardo-santos committed Jan 27, 2019
1 parent affd64a commit a25bf46
Show file tree
Hide file tree
Showing 53 changed files with 2,747 additions and 87 deletions.
50 changes: 0 additions & 50 deletions App.js

This file was deleted.

15 changes: 0 additions & 15 deletions __tests__/App.js

This file was deleted.

6 changes: 6 additions & 0 deletions android/app/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,11 @@ project.ext.react = [

apply from: "../../node_modules/react-native/react.gradle"

project.ext.vectoricons = [
iconFontNames: [ 'MaterialIcons.ttf' ] // Name of the font files you want to copy
]
apply from: "../../node_modules/react-native-vector-icons/fonts.gradle"

/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
Expand Down Expand Up @@ -134,6 +139,7 @@ android {
}

dependencies {
implementation project(':react-native-gesture-handler')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import android.app.Application;

import com.facebook.react.ReactApplication;
import com.swmansion.gesturehandler.react.RNGestureHandlerPackage;
import com.facebook.react.ReactNativeHost;
import com.facebook.react.ReactPackage;
import com.facebook.react.shell.MainReactPackage;
Expand All @@ -22,7 +23,8 @@ public boolean getUseDeveloperSupport() {
@Override
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage()
new MainReactPackage(),
new RNGestureHandlerPackage()
);
}

Expand Down
2 changes: 2 additions & 0 deletions android/settings.gradle
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
rootProject.name = 'GithubClient'
include ':react-native-gesture-handler'
project(':react-native-gesture-handler').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-gesture-handler/android')

include ':app'
12 changes: 12 additions & 0 deletions app/App.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
import React from "react";
import { Provider } from "react-redux";

import Navigator from "./config/routes";

import store from "./config/store";

export default () => (
<Provider store={store}>
<Navigator onNavigationStateChange={null} />
</Provider>
);
130 changes: 130 additions & 0 deletions app/__tests__/ActionLocationAdd-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,130 @@
import {
POST_API_LOCATION_ADD,
POST_API_LOCATION_ADD_SUCCESS,
POST_API_LOCATION_ADD_ERROR,
cleanResult,
apiPostLocationAdd
} from "../actions/apiLocationAdd";
import reducer from "../reducers/apiLocationAdd";

describe("actions locationAdd", () => {
const request = {
name: "Nome da Localização",
address: "Endereço da Localização",
phone: "(11) 12346-5432",
type: "Tipo da Localização",
lat: "10.2345",
lng: "-10.2345",
description: "Descrição da Localização"
};

it("should clean locationAdd state", () => {
const currentState = {
isApiSubmiting: false,
apiResultData: {
id: 2331,
createdBy: 9769,
name: "Nome da Localização",
address: "Endereço da Localização",
phone: "(11) 12346-5432",
type: "Tipo da Localização",
lat: "10.2345",
lng: "-10.2345",
description: "Descrição da Localização"
}
};

const expectedAction = {
isApiSubmiting: false,
apiResultData: null
};

expect(reducer(currentState, cleanResult())).toEqual(expectedAction);
});

it("should create an action to add a location", () => {
const expectedAction = {
type: POST_API_LOCATION_ADD,
location: request
};

expect(apiPostLocationAdd(request)).toEqual(expectedAction);
});

it("should start locationAdd API call", () => {
const currentState = {
isApiSubmiting: false,
apiResultData: null
};

const expectedAction = {
...currentState,
isApiSubmiting: true,
apiResultData: null
};

expect(reducer(currentState, apiPostLocationAdd(request))).toEqual(
expectedAction
);
});

it("should return locationAdd API success", () => {
const sagaSuccessResult = {
id: 2331,
createdBy: 9769,
name: "Nome da Localização",
address: "Endereço da Localização",
phone: "(11) 12346-5432",
type: "Tipo da Localização",
lat: "10.2345",
lng: "-10.2345",
description: "Descrição da Localização"
};

const currentState = {
isApiSubmiting: true,
apiResultData: null
};

const expectedAction = {
...currentState,
isApiSubmiting: false,
apiResultData: sagaSuccessResult
};

expect(
reducer(currentState, {
type: POST_API_LOCATION_ADD_SUCCESS,
sagaSuccessResult
})
).toEqual(expectedAction);
});

it("should return locationAdd API error", () => {
const sagaErrors = {
error: [
{
location: "body",
param: "name",
value: null,
msg: "`Name` necessita ser do tipo string"
}
]
};

const currentState = {
isApiSubmiting: true,
apiResultData: null
};

const expectedAction = {
...currentState,
isApiSubmiting: false,
apiResultData: sagaErrors
};

expect(
reducer(currentState, { type: POST_API_LOCATION_ADD_ERROR, sagaErrors })
).toEqual(expectedAction);
});
});
109 changes: 109 additions & 0 deletions app/__tests__/ActionLocationDetails-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import {
GET_API_LOCATION_DETAILS,
GET_API_LOCATION_DETAILS_SUCCESS,
GET_API_LOCATION_DETAILS_ERROR,
cleanResult,
apiGetLocationDetails
} from "../actions/apiLocationDetails";
import reducer from "../reducers/apiLocationDetails";

describe("actions locationDetails", () => {
const idLocation = 1349;

const apiResultData = {
id: idLocation,
createdBy: 9769,
name: "Nome da Localização",
address: "Endereço da Localização",
phone: "(11) 12346-5432",
type: "Tipo da Localização",
lat: "10.2345",
lng: "-10.2345",
description: "Descrição da Localização"
};

it("should clean locationDetails state", () => {
const currentState = {
isApiSubmiting: false,
apiResultData
};

const expectedAction = {
...currentState,
apiResultData: null
};

expect(reducer(currentState, cleanResult())).toEqual(expectedAction);
});

it("should create an action to get locationDetails", () => {
const expectedAction = {
type: GET_API_LOCATION_DETAILS,
idLocation
};

expect(apiGetLocationDetails(idLocation)).toEqual(expectedAction);
});

it("should start locationDetails API call", () => {
const currentState = {
isApiSubmiting: false,
apiResultData: null
};

const expectedAction = {
...currentState,
isApiSubmiting: true
};

expect(reducer(currentState, apiGetLocationDetails(idLocation))).toEqual(
expectedAction
);
});

it("should return locationDetails API success", () => {
const sagaSuccessResult = apiResultData;

const currentState = {
isApiSubmiting: true,
apiResultData: null
};

const expectedAction = {
...currentState,
isApiSubmiting: false,
apiResultData: sagaSuccessResult
};

expect(
reducer(currentState, {
type: GET_API_LOCATION_DETAILS_SUCCESS,
sagaSuccessResult
})
).toEqual(expectedAction);
});

it("should return locationDetails API error", () => {
const sagaErrors = {
error: "Localização não foi econtrada."
};

const currentState = {
isApiSubmiting: true,
apiResultData: null
};

const expectedAction = {
...currentState,
isApiSubmiting: false,
apiResultData: sagaErrors
};

expect(
reducer(currentState, {
type: GET_API_LOCATION_DETAILS_ERROR,
sagaErrors
})
).toEqual(expectedAction);
});
});
Loading

0 comments on commit a25bf46

Please sign in to comment.