Skip to content

Instantly share code, notes, and snippets.

Jun Kaneko goodpic

Block or report user

Report or block goodpic

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@goodpic
goodpic / HookTest.spec.ts
Created Sep 12, 2019
Test React Hooks with react-native-testing-library
View HookTest.spec.ts
import * as React from 'react'
import { fireEvent, render } from 'react-native-testing-library'
import { HookTest } from '../HookTest'
describe('Test Hooks', () => {
test('changeText', () => {
const { getByTestId, getByPlaceholder, queryByDisplayValue } = render(
<HookTest />)
@goodpic
goodpic / HookTest.tsx
Created Sep 12, 2019
React Native Hooks example to test
View HookTest.tsx
import * as React from 'react'
import { useState } from 'react'
import {
NativeSyntheticEvent, Text, TextInput, TextInputSubmitEditingEventData,
TouchableOpacity, View} from 'react-native'
interface IProps {
myMock?: () => void
}
View TestClass.tsx
import * as React from 'react';
import { Component } from 'react';
import { Text } from 'react-native';
interface IProps {
count?: number;
}
interface IState {
count: number;
}
View TestClass.spec.ts
import * as React from 'react';
import * as TestRenderer from 'react-test-renderer';
import TestClass from '../TestClass';
import TestHoc from '../TestHoc';
let renderer: TestRenderer.ReactTestRenderer;
describe("Test Component state change without HOC", () => {
beforeAll(() => {
renderer = TestRenderer.create(
View TestClass.spec.tsx
import * as React from 'react';
import * as TestRenderer from 'react-test-renderer';
import TestClass from '../TestClass';
import TestHoc from '../TestHoc';
let renderer: TestRenderer.ReactTestRenderer;
describe("Test Component state change without HOC", () => {
beforeAll(() => {
renderer = TestRenderer.create(
@goodpic
goodpic / react-native-example-for-test.js
Created Apr 10, 2019
react-native-example-for-test
View react-native-example-for-test.js
import * as React from 'react';
import { Component } from 'react';
import { Text } from 'react-native';
interface IProps {
count?: number;
}
interface IState {
count: number;
}
@goodpic
goodpic / ScannerScreen.js
Last active Apr 4, 2019
React Native Expo Barcode Scanner
View ScannerScreen.js
import React from 'react';
import {
ActivityIndicator,
View,
} from 'react-native'
import { ExpoScanner } from '../components/scanner/ExpoScanner';
class ScannerScreen extends React.Component {
constructor(props) {
@goodpic
goodpic / ExpoScanner.js
Last active Jan 4, 2019
Scan barcode with ReactNative Expo.js
View ExpoScanner.js
import React, { Component } from 'react';
import { Alert, View, Text, Vibration, StyleSheet } from 'react-native';
import { Camera, BarCodeScanner, Permissions } from 'expo';
export class ExpoScanner extends Component {
constructor(props) {
super(props);
this.onBarCodeRead = this.onBarCodeRead.bind(this);
this.renderMessage = this.renderMessage.bind(this);
View manifest.js
{
"timeZone": "Europe/London",
"dependencies": {
"enabledAdvancedServices": [
{
"userSymbol": "BigQuery",
"serviceId": "bigquery",
"version": "v2"
}, {
"userSymbol": "Drive",
View BigQuery_to_Google_sheet.js
// [START apps_script_bigquery_update_sheet]
/**
* Runs a BigQuery query and replace the existing sheet
*/
/**
* Add a custom menu to the spreadsheet when it is opened.
*/
function onOpen() {
var spreadsheet = SpreadsheetApp.getActive();
You can’t perform that action at this time.