Skip to content

Instantly share code, notes, and snippets.

View LeeCheneler's full-sized avatar

Lee Cheneler LeeCheneler

  • Enzyme Software
  • UK
  • 22:42 (UTC)
View GitHub Profile
@LeeCheneler
LeeCheneler / apollo-test-client.ts
Created August 5, 2020 22:34
apollo server test client with support for context
import { createTestClient } from "apollo-server-testing";
import { ApolloServer } from "apollo-server";
import {
createResolvers,
typeDefs,
createContext,
Context,
CreateContextOptions,
} from "./server";
import { DocumentNode } from "graphql";
@LeeCheneler
LeeCheneler / error-boundary-example-app.tsx
Last active June 3, 2020 09:18
Reporting error boundary with fallback
import React from "react";
import { ErrorBoundary } from "./error-boundary";
export const App = () => {
return (
<React.StrictMode>
<ErrorBoundary report={console.error}>
<h1>Example</h1>
</ErrorBoundary>
</React.StrictMode>
@LeeCheneler
LeeCheneler / run-cli-command.ts
Created April 13, 2020 22:10
run cli command for tests
import { spawn } from "child_process";
import terminate from "terminate";
export interface RunCliCommandOptions {
cwd?: string;
}
export const runCliCommand = (
command: string,
options: RunCliCommandOptions = { cwd: process.cwd() }
@LeeCheneler
LeeCheneler / extendExpect.ts
Last active April 14, 2020 11:38
expect.toContainInOrder
import chalk from "chalk";
const containsInOrder = (received: string[], expected: string[]) => {
let lastIndex = 0;
const lastOccuranceMap: { [key: string]: number } = {};
for (let e of expected) {
const index = received.indexOf(e);
// Not present at all
@LeeCheneler
LeeCheneler / example-usage.tsx
Last active September 12, 2019 07:01
useBreakpoint hook experiment
import React from "react";
import styled from "styled-components";
import { Box } "./some-styled-system";
import { useBreakpoints } from "./use-breakpoints";
// Very contrived example
const ColoredBox = styled.div<{ isRed: Boolean; isBlue: boolean }>`
width: 100px;
height: 100px;
@ramantehlan
ramantehlan / README-Fancy.md
Last active November 12, 2024 02:33
README template I use for most of my projects.

Introduction

  • Add your project logo.
  • Write a short introduction to the project.
  • If you are using badges, add them here.

📒 Index

@odytrice
odytrice / Ninject.Http.cs
Last active February 14, 2023 12:15
A small Library to configure Ninject (A Dependency Injection Library) with a WebAPI Application.
using Ninject.Modules;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Http;
using System.Web.Http.Dependencies;
// A small Library to configure Ninject (A Dependency Injection Library) with a WebAPI Application.
@odytrice
odytrice / Ninject.Mvc.cs
Last active December 12, 2022 11:48
A small Library to configure Ninject (A Dependency Injection Library) with an ASP.NET Application.
using Ninject;
using Ninject.Modules;
using Ninject.Web.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Web;
using System.Web.Mvc;