Skip to content

Instantly share code, notes, and snippets.

@axelnormand
axelnormand / Link.tsx
Created May 13, 2021 11:52 — forked from tj-mc/Link.tsx
rnw-link-component
@axelnormand
axelnormand / machine.js
Last active December 1, 2020 11:37
Generated by XState Viz: https://xstate.js.org/viz
//
// Paste into: https://xstate.js.org/viz/
// Trying out a state chart to model the idea flow
//
// Available variables:
// - Machine
// - interpret
// - assign
// - send
@axelnormand
axelnormand / machine.js
Created October 8, 2020 16:21
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@axelnormand
axelnormand / machine.js
Last active October 7, 2020 14:01
Generated by XState Viz: https://xstate.js.org/viz
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
// - XState (all XState exports)
@axelnormand
axelnormand / jest.setup.js
Created July 30, 2018 11:13
React Native Jest
// Setup for use with enzyme
// Patching console.error so test will fail
const Enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
Enzyme.configure({ adapter: new Adapter() });
//fix redux saga test plan which needs setTimeout on window
global.window.setTimeout = global.setTimeout;
@axelnormand
axelnormand / initStorybookUI.ts
Created July 30, 2018 10:33
React Native Stroybook
import { configure, getStorybookUI } from '@storybook/react-native';
import React from 'react';
import { getConfig } from 'src/config';
import {
allStories,
loadStories,
} from 'src/test/storybook/storyshots/allStories';
/**
* init storybook UI on app startup and returns component ready, but dont display yet
@axelnormand
axelnormand / testTemplate.ts
Last active December 5, 2022 15:14
React Native Storybook
///////////////////
// AUTO GENERATED by createTests.ts
// This is the storyshot for the story file
// One test file per story to help test watching
///////////////////
import { getSnapshotFileName } from '@storybook/addon-storyshots';
import { shallow } from 'enzyme';
import toJson from 'enzyme-to-json';
import React from 'react';
@axelnormand
axelnormand / testStory.tsx
Created July 30, 2018 10:32
React Native Storybook
import { storiesOf } from '@storybook/react-native';
import React from 'react';
import { Text, View } from 'react-native';
const TestComponent: React.SFC<{}> = () => <Text>Hello world!</Text>;
/**
* A test story for testTemplate to use
*
* Test Decorator should not be in snapshot be design
@axelnormand
axelnormand / storybookStore.ts
Created July 30, 2018 10:32
React Native Storybook
import { action } from '@storybook/addon-actions';
import { Store } from 'redux';
import { getInitialState } from '../state';
/**
* Ready only mock store with addon actions upon dispatch
*
* Defaults to having a valid App initial state as imported via state.ts
*/
export const getStorybookStore = (): Store<any> => {
@axelnormand
axelnormand / setupSnapshotTest.ts
Created July 30, 2018 10:31
React Native Storybook
import addons from '@storybook/addons';
import { createMockChannel } from 'src/test/storybook/storyshots/mockChannel';
//
// This runs to mock things required for the jest snapshot of a story
//
// In generated test, import this straight as `import 'src/test/storybook/storyshots/setupSnapshotTest'`
// Then require mocked storybook methods
// `const { configure, getStorybook } = require('@storybook/react-native');`
//