Skip to content

Instantly share code, notes, and snippets.

View Nfinley's full-sized avatar

Nigel Finley Nfinley

View GitHub Profile
@Nfinley
Nfinley / Jest-Test-Component-Snippet
Created March 22, 2018 23:29
A jest snippet to test a component
import React from 'react';
import {shallow} from 'enzyme';
import $ComponentName$ from '$filepath$'
describe('$ComponentName$ Test', () => {
const props = {};
const wrapper = shallow(<$ComponentName$ {...props}/>);
describe('$ComponentName$ State Test', () => {
it('Should have the correct state', () => {
@Nfinley
Nfinley / Jest-Test-Action-Snippet
Last active March 22, 2018 23:27
A jest snippet for testing an action file
import configureMockStore from 'redux-mock-store';
import thunk from 'redux-thunk';
import * as $actionFileName$ from './$actionFileName$';
import * as Constants from '../constants/Constants';
const middlewares = [thunk];
const mockStore = configureMockStore(middlewares);
describe('$actionFileName$', () => {
//Test all actions
@Nfinley
Nfinley / Jest-Test-Reducer-Snippet
Last active March 19, 2018 19:00
A jest snippet for testing a reducer
import $reducerName$ from './$reducerName$';
import * as $actionName$ from '../actions/$actionName$';
//A reducer should return the new state after applying the action to the previous state
describe('$reducerName$ Reducer', () => {
const initialState = {
id: '',
name: 'test'
};
const templates = [{
@Nfinley
Nfinley / React-Create-Stateless-Snippet
Last active June 11, 2018 04:50
A react snippet for a stateless component
import React from 'react';
import PropTypes from 'prop-types';
const propTypes = {};
const defaultProps = {};
function $ComponentName$({ props }) {
return (
<div className="">
@Nfinley
Nfinley / React-Create-Class-Snippet
Last active June 12, 2018 22:31
A snippet for creating a react class component
import React, { Component } from 'react';
import PropTypes from 'prop-types';
class $ComponentName$ extends Component {
static propTypes = {
// myProp: PropTypes.string.isRequired
};
static defaultProps = {};
constructor(props) {
@Nfinley
Nfinley / Nigel-Finley-Resume.md
Last active November 5, 2018 16:14
Nigel Finley Resume