Skip to content

Instantly share code, notes, and snippets.

View adamTrz's full-sized avatar
🎯
Focusing

Adam Trzciński adamTrz

🎯
Focusing
View GitHub Profile
@adamTrz
adamTrz / index.vr.js
Last active February 24, 2018 18:26
Sphere
import React from 'react';
import { AppRegistry, Sphere, View, PointLight } from 'react-vr';
export default class vr_universe extends React.Component {
render() {
return (
<View>
<Sphere
heightSegments={20}
widthSegments={20}
@adamTrz
adamTrz / rn-ios-kit-custom-theme.js
Created January 15, 2018 10:08
react-native-ios-kit theme customisation
import * as React from 'react';
import { AppRegistry } from 'react-native';
import { DefaultTheme, ThemeProvider } from 'react-native-ios-kit';
import color from 'color';
import App from './src/App';
const theme = {
...DefaultTheme,
primaryColor: 'tomato',
primaryLightColor: color('tomato').lighten(0.2).rgb().string(),
@adamTrz
adamTrz / rn-ios-kit-search-bar.js
Created January 15, 2018 09:14
react-native-ios-kit SearchBar example
/* @flow */
import React, { Component } from 'react';
import { View, StyleSheet } from 'react-native';
import { withTheme, SearchBar } from 'react-native-ios-kit';
import type { Theme } from 'react-native-ios-kit/types';
type Props = {
theme: Theme,
};
@adamTrz
adamTrz / rn-ios-kit-theme-provider.js
Last active January 15, 2018 09:15
react-native-ios-kit ThemProvider
import * as React from 'react';
import { AppRegistry } from 'react-native';
import { ThemeProvider } from 'react-native-ios-kit';
import App from './src/App';
function Main() {
return (
<ThemeProvider>
<App />
</ThemeProvider>
const baseUrlMatcher = new RegExp('localhost:3000/$');
describe('Log out user properly', () => {
// log in before each test:
beforeEach(() => {
cy.login('test@email.com', 'password');
});
it('can select dropdown and perform logout action', () => {
// check if we are logged in:
cy.url().should('contains', '/c/');
Cypress.Commands.add('login', (email, password) => {
// Make a POST request to our backend
// We are using GraphQL, so as a body we are passing mutation:
cy
.request({
url: 'http://localhost:4000/graphql',
method: 'POST',
body: {
query:
'mutation login($email: String!, $password: String!) {loginUser(email: $email, password: $password)}',
describe('Log In', () => {
it('succesfully performs login action', () => {
...
});
it('displays error message when login fails', () => {
// go directly to login path
cy.visit('/login');
// try to log in with incorect credentials
cy.get('input[data-testid="login-form-username"]').type('test@email.com');
cy.get('input[data-testid="login-form-password"]').type('fail_password');
describe('Log In', () => {
it('succesfully performs login action', () => {
// visit 'baseUrl'
cy.visit('/');
// assert if we are in good place - search for a 'smarter world phrase
cy.contains('smarter world');
// search for a div with 'Teachers' caption, and click it
cy.get('a[data-testid="main-link-teachers"]').click();
// check if url have changed
cy.url().should('includes', 'teachers');
//App.js:
...
connect(mapStateToProps, { fetchData })(App)
//ActionCreator:
export const fetchData = () => (dispatch) => {
dispatch({type: FETCHING_DATA})
getPeople()
.then(data => dispatch({type: FETCHING_DATA_SUCCESS, payload: data}))
.catch(er => dispatch({type: FETCHING_DATA_FAILURE}))