Skip to content

Instantly share code, notes, and snippets.

Avatar

Fabrício Ferrari de Campos FabricioFFC

View GitHub Profile
View TeamDetails.test.js
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import { ActivityIndicator} from 'react-native';
import nock from 'nock';
import TeamDetailsScreen from '../../../src/screens/TeamDetails';
import TeamDetails from '../../../src/components/TeamDetails';
import brazilMock from '../../fixtures/teams/brazil.json';
const asyncFlush = () => new Promise(resolve => setTimeout(resolve, 100));
View Home.test.js
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import HomeScreen from '../../../src/screens/Home';
import TeamsList from '../../../src/components/TeamsList';
describe('HomeScreen', () => {
describe('render', () => {
it('show TeamsList component', () => {
View TeamsList.test.js
import React from 'react';
import ShallowRenderer from 'react-test-renderer/shallow';
import { ActivityIndicator, FlatList } from 'react-native';
import nock from 'nock';
import TeamsList from '../../../src/components/TeamsList';
import teamsListExpectedData from '../../fixtures/httpResponses/teamsList'
const asyncFlush = () => new Promise(resolve => setTimeout(resolve, 100));
View TeamItem.test.js
import React from 'react';
import renderer from 'react-test-renderer';
import humps from 'humps';
import { TouchableOpacity } from 'react-native';
import TeamItem from '../../../src/components/TeamItem';
import brazilMock from '../../fixtures/teams/brazil.json';
const brazilTeam = humps.camelizeKeys(brazilMock);
View TeamDetails.js
import React from 'react';
import PropTypes from 'prop-types';
import {
StyleSheet,
Image,
View,
Text,
FlatList,
Dimensions,
} from 'react-native';
View httpRequest.js
import axios from 'axios';
import humps from 'humps';
async function get(url) {
try {
const response = await axios.get(url);
return humps.camelizeKeys(response.data);
} catch ({ response }) {
return {
View TeamDetails.test.js
import React from 'react';
import renderer from 'react-test-renderer';
import humps from 'humps';
import TeamDetails from '../../../src/components/TeamDetails';
import brazilMock from '../../fixtures/teams/brazil.json';
const brazilTeam = humps.camelizeKeys(brazilMock);
describe('TeamDetails', () => {
View TeamDetails.js
import React from 'react';
import PropTypes from 'prop-types';
import {
StyleSheet,
Image,
View,
Text,
FlatList,
Dimensions,
} from 'react-native';
View httpRequest.js
const axios = require('axios');
async function get(url) {
try {
const response = await axios.get(url);
return response.data;
} catch ({ response }) {
return {
status: response.status,
View httpRequest.test.js
import nock from 'nock';
import httpRequest from '../../../src/services/httpRequest';
import teamsListExpectedData from '../../fixtures/httpResponses/teamsList'
describe('httpRequest', () => {
describe('.get', () => {
it('returns the data from the http endpoint', async () => {
// given
nock('http://mock-api.com.br')