Skip to content

Instantly share code, notes, and snippets.

import { addStateListeners } from './storeObserver'
import { addPostDispatchListeners } from './listenerMiddleware'
let startTime = null
let dataLoaded = true
let pageRendered = false
const start = (time) => {
startTime = time
dataLoaded = true
import React, { Component } from 'react';
import ReactDOM from 'react-dom';
let instance = null;
export const getTop = () => {
return instance.getTop();
}
export default class InjectPoint {
import React, {Component} from 'react'
import {connect} from 'react-redux'
import classNames from 'classnames'
class InjectPoint extends Component {
render () {
const {popUpStack} = this.props
const children = popUpStack.map((item, i) => {
const clonedChild = React.cloneElement(item.Component, {
...item.Component.props,
@damon-kreft
damon-kreft / 1-productsData.js
Last active March 29, 2017 14:22
Unit Testing Using Dependency Injection
// Super simple data layer for fetching raw product data from the server
export const defaultOptions = {
headers: {
'Content-Type': 'application/json'
}
};
const mergeOptions = (...options) => {
return Object.assign({}, defaultOptions, ...options);
};
@damon-kreft
damon-kreft / isomorphic-fetch-mock.js
Last active March 29, 2017 12:44
Unit Testing Using Mocked Imports
// A simple isomorphic-fetch mock that returns what you pass into it so we can assert that the methods in products.js
// are passing the correct values (I'd add rejection logic in here too to test those cases but this is just for demo purposes)
const fetch = (url, options) => {
return Promise.resolve({url, options});
};
export default fetch;
# Your init script
#
# Atom will evaluate this file each time a new window is opened. It is run
# after packages are loaded/activated and after the previous editor state
# has been restored.
#
# An example hack to log to the console when each text editor is saved.
#
# atom.workspace.observeTextEditors (editor) ->
# editor.onDidSave ->