Skip to content

Instantly share code, notes, and snippets.

View Eightyplus's full-sized avatar

Morten Friesgaard Eightyplus

View GitHub Profile
class Test {
@Test
fun `should test recycler`() {
onData(is(instanceOf(ItemModel.class)))
.atPosition(0)
.onChildView(withId(R.id.item_image))
.perform(click())
@Eightyplus
Eightyplus / mockRelay.js
Created October 31, 2019 11:34
Mock of react-relay
/**
* How to use, place mockRelay in mock files or where you like
*
* jest.mock('react-relay', () => require('./mockRelay').mockRelay);
*/
import QueryRenderer from './mockQueryRenderer'
const mockComponent = Component => props => <Component ...props />;
exports.mockRelay = {
@Eightyplus
Eightyplus / bash.sh
Last active November 11, 2019 12:20
git stuff
alias gb="git branch"
alias cleangit="git branch | egrep -vE \"^\*|master\" | xargs git branch -d"
alias swapgit="git branch | egrep -vEm1 \"^\*\" | xargs git checkout "
gc() { git branch | grep "$*" | xargs git checkout;}
alias cleanit="git pull && git remote prune origin && cleangit"
@Eightyplus
Eightyplus / .bashrc
Created June 4, 2019 10:32
aliases or usefull commands
grep -R --exclude-dir=node_modules "Dialog" * | sed 's/\/.*//g' | sort | uniq
@Eightyplus
Eightyplus / jest.test.js
Last active May 10, 2019 18:01
Mock window.location in jest
describe('test reading window.location', () => {
beforeEach(() =>
window.history.replaceState(
{},
'Title',
'/?code=0123456789&other=yes'
)
);
it('should have code', () => {
@Eightyplus
Eightyplus / rc.local
Last active January 9, 2019 11:30
raspberry pi starting tvservice based on connected devices
#!/bin/sh
# edit /etc/rc.local
wifi_loaded=`dmesg | grep "ieee80211"`
if [ -n "$wifi_loaded" ]; then
/usr/bin/tvservice -o
fi
import relay from 'react-relay';
jest.mock('react-relay');
const mockQueryRenderer = props => {
return class QueryRendererMock extends Component {
render() {
return this.props.render({
props: {
...props
}
@Eightyplus
Eightyplus / mockNamedExports.jsx
Created November 12, 2018 08:46
mock named exports, in this case `createFragmentContainer` and `withRouter`
jest.mock('react-relay', () => ({
createFragmentContainer: Component => props => <Component {...props} />
}));
jest.mock('react-router', () => ({
withRouter: Component => props => <Component {...props} />
}));
@Eightyplus
Eightyplus / InputAutoComplete.jsx
Created June 15, 2018 08:08
React auto-complete input
import React, { Component } from 'react';
export default class InputAutoComplete extends Component {
constructor (props) {
super(props);
this.options = ['britain', 'ireland', 'norway', 'sweden', 'denmark', 'germany', 'holland', 'belgium', 'france', 'spain', 'portugal', 'italy', 'switzerland'];
this.state = {
input: '',
selected: false