Skip to content

Instantly share code, notes, and snippets.

View trooperandz's full-sized avatar

Matt Holland trooperandz

View GitHub Profile
@trooperandz
trooperandz / test-user-example.js
Last active August 14, 2022 16:53
Testing philosophies user test example
describe("UserTest", () => {
it("Handles the shipment card press event", () => {
const { getByTestId } = renderComponent();
fireEvent.press(getByTestId(SHIPMENT_CARD));
expect(mockPressHandler).toHaveBeenCalled();
});
it("Renders the shipment number", async () => {
@trooperandz
trooperandz / test-engineer-example.js
Last active August 14, 2022 17:12
Testing philosophies engineer test example
describe("EngineerTest", () => {
it("Creates the touchable area for the shipment card", () => {
const renderedView = renderComponent();
expect(renderedView.type).toBe(TouchableOpacity);
expect(renderedView.props.activeOpacity).toBe(0.6);
expect(renderedView.props.accessibilityRole).toBe("button");
});
it("Calls useState", () => {
@trooperandz
trooperandz / index.js
Last active November 16, 2021 18:02
React Native Storybook storybook/stories/index.js import file
// storybook/stories/index.js
import './Button/index.stories';
@trooperandz
trooperandz / index.js
Last active November 16, 2021 18:04
React Native Storybook main project index file
// Main project root index.js file, adjusted to run storybook
// import { AppRegistry } from 'react-native';
// import App from './App';
// import { name as appName } from './app.json';
// AppRegistry.registerComponent(appName, () => App);
export { default } from './src/storybook';
@trooperandz
trooperandz / package.json
Created November 15, 2021 00:35
React Native Storybook package.json story loader snippet
{
"scripts": {
"prestorybook": "rnstl"
},
"config": {
"react-native-storybook-loader": {
"searchDir": [
"./src"
],
"pattern": "**/*.stories.js",
@trooperandz
trooperandz / index.js
Created November 15, 2021 00:13
React Native Storybook story loader index file
import { AppRegistry } from 'react-native';
import {
getStorybookUI,
configure,
addDecorator,
} from '@storybook/react-native';
import { withKnobs } from '@storybook/addon-knobs';
import { loadStories } from './storyLoader';
import './rn-addons';
@trooperandz
trooperandz / icon-search
Last active November 16, 2021 18:06
React Native Storybook search SVG icon
@trooperandz
trooperandz / index.js
Created November 14, 2021 22:45
React Native Storybook CenterView file
// storybook/CenterView/index.js
import React from 'react';
import { StyleSheet, View } from 'react-native';
export const CenterView = ({ children }) => {
return <View style={styles.container}>{children}</View>;
};
const styles = StyleSheet.create({
@trooperandz
trooperandz / index.stories.js
Last active November 15, 2021 02:08
React Native Storybook Button story file
// storybook/Button/index.stories.js
import React from 'react';
import { storiesOf } from '@storybook/react-native';
import { action } from '@storybook/addon-actions';
import { text, select, boolean } from '@storybook/addon-knobs';
import { CenterView } from '../CenterView';
import { Button } from '.';
const typeOptions = ['primary', 'secondary', 'tertiary'];
@trooperandz
trooperandz / index.js
Last active November 15, 2021 02:07
React Native Storybook Button
// storybook/Button/index.js
import React from 'react';
import {
ActivityIndicator,
StyleSheet,
Text,
TouchableOpacity,
View,
} from 'react-native';