Skip to content

Instantly share code, notes, and snippets.

View oieduardorabelo's full-sized avatar

Eduardo Rabelo oieduardorabelo

View GitHub Profile
@belminf
belminf / cloudfront_distro.yaml
Created April 26, 2017 23:20
Example of an empty S3OriginConfig
AWSTemplateFormatVersion: 2010-09-09
Resources:
Bucket:
Type: 'AWS::S3::Bucket'
Properties:
AccessControl: PublicRead
WebsiteConfiguration:
IndexDocument: index.html
ErrorDocument: error.html
Distro:
@singledigit
singledigit / cognito.yaml
Last active December 11, 2024 10:03
Create a Cognito Authentication Backend via CloudFormation
AWSTemplateFormatVersion: '2010-09-09'
Description: Cognito Stack
Parameters:
AuthName:
Type: String
Description: Unique Auth Name for Cognito Resources
Resources:
# Creates a role that allows Cognito to send SNS messages
SNSRole:
// how I share state anywhere in the tree
<Route render={({ match: { params } }) => ()}/>
<Geolocation>
{coords => ()}
</Geolocation>
<FirebaseRef path="/somewhere">
{(doc) => ()}
</FirebaseRef>
@lelandrichardson
lelandrichardson / react-native.js
Last active July 21, 2022 17:56
React Native flow types
declare var __DEV__: boolean;
declare module 'react-native' {
declare type Color = string | number;
declare type Transform =
{ perspective: number } |
{ scale: number } |
{ scaleX: number } |
@stipsan
stipsan / Sidebar-test.jsx
Last active June 16, 2017 09:34
Testing with Jest: Tip #1
import renderer from 'react-test-renderer'
import Sidebar from '../Sidebar'
jest.mock('react-router-dom/Link', () => 'Link')
it('should render correctly', () => {
const component = renderer.create(<Sidebar />)
expect(component.toJSON()).toMatchSnapshot()
})
@stipsan
stipsan / Sidebar-test.jsx
Last active June 16, 2017 09:35
Testing with Jest: Tip #2
import renderer from 'react-test-renderer'
import Sidebar from '../Sidebar'
jest.mock('react-router-dom', () => ({ Link: 'Link' }))
it('should render correctly', () => {
const component = renderer.create(<Sidebar />)
expect(component.toJSON()).toMatchSnapshot()
})
@stipsan
stipsan / Header-test.jsx
Last active June 16, 2017 09:40
Testing with Jest: Tip #4
import renderer from 'react-test-renderer'
import Header from '../Header'
import store from '../store'
jest.mock('react-redux-loading-bar', () => {
const ReactReduxLoadingBar = require.requireActual('react-redux-loading-bar')
return {
// Spread out the original module
...ReactReduxLoadingBar,
@stipsan
stipsan / Sidebar-test.jsx
Last active December 19, 2023 12:43
Testing with Jest: Tip #5
import renderer from 'react-test-renderer'
import Sidebar from '../Sidebar'
jest.mock('react-router-dom', () => ({
Link: 'Link',
Route: ({ children, path }) => children({ match: path === '/somewhere' })
}))
it('should render correctly', () => {
const component = renderer.create(<Sidebar />)
@stipsan
stipsan / Select-test.jsx
Last active June 16, 2017 09:36
Testing with Jest: Tip #3
import renderer from 'react-test-renderer'
import Select from '../Select'
jest.mock('react-select', () => {
const { createElement } = require('react')
// Note that since 'react-select' is mocked we have to use
// require.requireActual, even inside the factory function that mocks it!
// Just watch the movie Inception and skip to the Dream within a Dream and you'll get it
const ReactSelect = require.requireActual('react-select')
@stipsan
stipsan / App-test.jsx
Last active June 16, 2017 09:44
Testing with Jest: Tip #6
import renderer from 'react-test-renderer'
import App from '../App'
jest.mock('react-router-dom', () => ({
Link: 'Link',
Route: ({ children, ...props }) =>
typeof children === 'function'
? children({ match: path === '/somewhere' })
: createElement('Route', props)
}))