Skip to content

Instantly share code, notes, and snippets.

View goodpic's full-sized avatar

Jun Kaneko goodpic

View GitHub Profile
@goodpic
goodpic / HookTest.spec.ts
Created September 12, 2019 17:12
Test React Hooks with react-native-testing-library
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 September 12, 2019 17:10
React Native Hooks example to test
import * as React from 'react'
import { useState } from 'react'
import {
NativeSyntheticEvent, Text, TextInput, TextInputSubmitEditingEventData,
TouchableOpacity, View} from 'react-native'
interface IProps {
myMock?: () => void
}
import * as React from 'react';
import { Component } from 'react';
import { Text } from 'react-native';
interface IProps {
count?: number;
}
interface IState {
count: number;
}
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(
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 April 10, 2019 16:09
react-native-example-for-test
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 April 4, 2019 12:44
React Native Expo Barcode Scanner
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 September 5, 2022 12:27
Scan barcode with ReactNative Expo.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);
{
"timeZone": "Europe/London",
"dependencies": {
"enabledAdvancedServices": [
{
"userSymbol": "BigQuery",
"serviceId": "bigquery",
"version": "v2"
}, {
"userSymbol": "Drive",
// [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();