Skip to content

Instantly share code, notes, and snippets.

Avatar

Joseph McCormick esmevane

View GitHub Profile
@esmevane
esmevane / paths.ts
Last active Sep 13, 2021
[ Typescript ]: Strongly typed, filterable keypaths
View paths.ts
type GetKeypaths<
GivenType,
Filter extends string = '___!!!PLACEHOLDER!!!___'
> = GivenType extends object
? keyof GivenType extends string
? keyof GivenType extends Filter
? GetKeypaths<GivenType[keyof GivenType], Filter>
:
| keyof GivenType
| `${keyof GivenType}.${GetKeypaths<
View SketchSystems.spec
App
Checking Credentials
Identity Present -> Home Page
Identity Absent -> Registration
Registration
Check for Identity Info
Identity Info Present -> Registration Credentials Form
Identity Info Absent -> Identity Info Form
Identity Info Form
Input Identity Info -> Validating Identity Info
@esmevane
esmevane / toggle.spec.tsx
Created Jul 28, 2021
[ React / Typescript ]: Example of an architectural journey with a React Toggle component
View toggle.spec.tsx
/* eslint-disable @typescript-eslint/require-await */
import { render } from '@testing-library/react';
import userEvent from '@testing-library/user-event';
import { createContext, useContext, useReducer } from 'react';
type Events = { type: 'toggle' } | { type: 'reset' };
interface EventMap {
toggle: () => void;
reset: () => void;
}
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions
View SketchSystems.spec
Touchpoint Dashboard
Loading
Success -> Authenticating
Failure -> Unable to Load
Unable to Load
Retry -> Loading
Authenticating
Checking Credentials
No Credentials -> Login
Credentials Exist -> Verify Credentials
@esmevane
esmevane / SketchSystems.spec
Last active Oct 11, 2020
Touchpoint Dashboard
View SketchSystems.spec
Touchpoint Dashboard
Loading*
Success -> Authenticating
Failure -> Unable to Load
Unable to Load
Retry -> Loading
Authenticating
Checking Credentials?
No Credentials -> Login
Credentials Exist -> Authenticate
View SketchSystems.spec
Widget&
Async
Pending
Fetch -> Fetching
Fetching
Resolved -> Success
Rejected -> Failure
Success
Fetch -> Fetching
Failure
@esmevane
esmevane / App.test.tsx
Created Jun 2, 2020
[ Typescript / React ]: Login kata 06-02-2020
View App.test.tsx
import React from 'react';
import { render, fireEvent } from '@testing-library/react';
import App, { AppContext } from './App';
const SpiesOnApp = () => {
const context = React.useContext(AppContext);
return <>{JSON.stringify(context)}</>;
};
test('tracks username', async () => {
View SketchSystems.spec
Explorer
Uninitialized
Rehydrate -> Ready
Ready&
Requesting -> Ready
Results
Idle
Requesting -> Loading
Loading
Success -> Idle
View machine.js
// Available variables:
// - Machine
// - interpret
// - assign
// - send
// - sendParent
// - spawn
// - raise
// - actions