Skip to content

Instantly share code, notes, and snippets.

View overengineered's full-sized avatar

Juozas Kontvainis overengineered

View GitHub Profile
import 'react-native';
import {act} from 'react-test-renderer';
import {componentDriver} from 'react-component-driver';
import Example from '../App';
const getExampleDriver = () => componentDriver(Example, {
toggleAwesome(value) {
this.getByID('awesome').props.onValueChange(value);
return this;
},
import React from 'react';
import {Button, SafeAreaView, Switch, Text, View} from 'react-native';
function CheckBox({value, label, onValueChange, testID}) {
return (
<View style={{flexDirection: 'row', justifyContent: 'space-between', padding: 10}}>
<Text>{label}</Text>
<Switch onValueChange={onValueChange} value={value} testID={testID}/>
</View>
);
const mockAsBasicComponent = (name) => {
const React = require('react');
const RealComponent = require.requireActual(name);
const BasicComponent = {[name]: props => React.createElement(name, props)}[name];
BasicComponent.propTypes = RealComponent.propTypes;
return BasicComponent;
}
jest.mock('TouchableOpacity', () => mockAsBasicComponent('TouchableOpacity'));
jest.mock('Switch', () => mockAsBasicComponent('Switch'));
@overengineered
overengineered / gist:146dc95e21e17d263e37
Created August 27, 2014 07:14
Install pip on Raspberry PI
curl -O http://python-distribute.org/distribute_setup.py
python distribute_setup.py
curl -O https://bootstrap.pypa.io/get-pip.py
python get-pip.py