Skip to content

Instantly share code, notes, and snippets.

View jasongaare's full-sized avatar
😋
Hungry

Jason Gaare jasongaare

😋
Hungry
View GitHub Profile
import mockStore from 'redux-mock-store';
import { authenticateUser } from 'actions/sessions';
import { LOGOUT } from 'constants/actions';
import user from 'reducers/user';
import { testUser } from 'jest/mock-objects';
describe('Testing log in authentication', () => {
const store = mockStore();
beforeEach(() => {
exports[`Testing log in authentication attempt with correct password succeeds 1`] = `
Array [
Object {
"type": "LOGIN_STARTED",
},
Object {
"type": "PROFILE_UPDATED",
"user": Object { ... },
},
Object {
import MockAdapter from 'axios-mock-adapter';
import apiClient from 'helpers/api-client';
import { userObject } from 'jest/mockResponseObjects/user-objects';
const mockApi = new MockAdapter(apiClient.getAxiosInstance());
const validAuth = '{"email":"email@test.com","password":"password"}';
mockApi.onPost('sessions').reply((config) => {
if (config.data === validAuth) {
return [200, userObject];
import mockStore from 'redux-mock-store';
const store = mockStore();
describe('Testing log in authentication', () => {
beforeEach(() => {
store.clearActions();
});
it('attempt with correct password succeeds', async () => {
await store.dispatch(authenticateUser('email@test.com', 'password'));
jest.mock('Animated', () => {
return {
createTimer: jest.fn(),
timing: jest.fn(() => {
return {
start: jest.fn(),
};
}),
Value: jest.fn(() => {
return {
import MockAdapter from 'axios-mock-adapter';
import apiClient from 'helpers/api-client';
import { userObject } from 'jest/mockResponseObjects/user-objects';
import mockStore from 'redux-mock-store';
const mockApi = new MockAdapter(apiClient.getAxiosInstance());
const validAuth = '{"email":"email@test.com","password":"password"}';
const store = mockStore();
mockApi.onPost('sessions').reply((config) => {
import styled from 'styled-components/native';
import { isTablet } from 'helpers/device-info';
const SettingsWrapper = styled.View`
padding: 0px ${isTablet ? '96px' : '0px'};
flex: 1;
`;
const SettingsHeader = styled.Text`
font-size: 16px;
import { Dimensions } from 'react-native';
const isTablet = Math.min(
Dimensions.get('window').width,
Dimensions.get('window').height) >= 768;
export { isTablet };
render() {
return(
<SettingsWrapper>
<SettingsHeader>Preferences</SettingsHeader>
...
</SettingsWrapper>
);
}
import CardStackStyleInterpolator from 'react-navigation/src/views/CardStack/CardStackStyleInterpolator';
import { Animated, Easing, Platform } from 'react-native';
const {
forHorizontal,
forVertical,
forFadeFromBottomAndroid,
forFade,
} = CardStackStyleInterpolator;