Scientific Method | TDD |
---|---|
Question | Requirement |
Prediction | Expected Output |
Experiment | Test Assertion |
Subject | Implementation Code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { compose } from 'lodash/fp'; | |
import withFeatures from './with-features'; | |
import withEnv from './with-env'; | |
import withLoader from './with-loader'; | |
import withCoupon from './with-coupon'; | |
import withLayout from './with-layout'; | |
import withAuth from './with-auth'; | |
import { withRouter } from 'next/router'; | |
import withMagicLink from '../features/ethereum-authentication/with-magic-link'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect } from 'react'; | |
import hoistStatics from '../../HOCs/hoist-statics'; | |
import { connect } from 'react-redux'; | |
import { | |
getShouldSignOut, | |
setShouldSignOut, | |
getDidAuthFail, | |
signInStatusChanged, | |
setMagicUser, | |
} from './ethereum-authentication-reducer'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const createUser = ({ | |
email = '', | |
publicAddress = '', | |
sessionToken = '', | |
isSignedIn = false, | |
} = {}) => ({ | |
email, | |
publicAddress, | |
sessionToken, | |
isSignedIn, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState } from 'react'; | |
const configureLocalStorage = key => initialValue => { | |
const [state, setState] = useState(() => { | |
try { | |
const value = localStorage.getItem(key); | |
return value ? JSON.parse(value) : initialValue; | |
} catch (e) { | |
console.log(e); | |
return initialValue; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useRef } from 'react'; | |
const usePromise = () => { | |
const ref = []; | |
const container = useRef(ref); | |
ref[0] = new Promise((resolve, reject) => { | |
ref[1] = resolve; | |
ref[2] = reject; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Trying to replicate this easy-as-pie Haskell type: | |
// fmap:: (a -> b) -> f a -> f b | |
// And failing miserably. | |
// OK, verbose, but I think we're on the right track... | |
// First, we define functor. | |
interface Functor<T> { | |
map<U> (f: (x: T) => U): Functor<U> | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useState, useEffect, useRef } from 'react'; | |
import Web3 from 'web3'; | |
import Fortmatic from 'fortmatic'; | |
const usePromise = () => { | |
const ref = []; | |
const container = useRef(ref); | |
ref[0] = new Promise((resolve, reject) => { | |
ref[1] = resolve; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//------------------------------------------------------------- | |
// | |
// Hypothesis: | |
// | |
// Promises/A is a Monad | |
// | |
// To be a Monad, it must provide at least: | |
// - A unit (aka return or mreturn) operation that creates a corresponding | |
// monadic value from a non-monadic value. | |
// - A bind operation that applies a function to a monadic value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Teacher extends User { | |
constructor (options) { | |
super(options); | |
this.lessons = []; | |
} | |
createLesson (lesson) { | |
const { name } = lesson; | |
this.lessons.push(lesson); | |
console.log(`${ this.name } created lesson: ${ name }`); | |
} |