Skip to content

Instantly share code, notes, and snippets.

View JakeDawkins's full-sized avatar

Jake Dawkins JakeDawkins

View GitHub Profile
@JakeDawkins
JakeDawkins / FloatingLabelInput.tsx
Last active September 27, 2023 05:33
Input with Floating Label
import { InputHTMLAttributes, useMemo, forwardRef } from 'react';
import ReactInputMask from 'react-input-mask';
import styles from './index.module.css';
type FloatingLabelInputProps = InputHTMLAttributes<HTMLInputElement> & {
label: string;
mask?: string;
className?: string;
errorMessage?: string;
};
@JakeDawkins
JakeDawkins / config.ts
Last active July 23, 2019 19:45
Apollo config 3.0
// TO VIEW THE WORK DONE ON LOADING EN EXPERIMENTAL CONFIG, SEE THIS BRANCH:
// https://github.com/apollographql/apollo-tooling/compare/jake/experimental-config
/**
* Goal: rebuild apollo config to allow for easier configuration
*
* Ideas:
* - More top-level options with fewer nested keys
* - I don't think field nesting is strictly necessary, since a _lot_
* of things are duplicated between client/service projects (like includes)
@JakeDawkins
JakeDawkins / startTestServer-express.js
Created July 31, 2018 20:00
how to e2e test an ApolloServer instance
import { HttpLink } from 'apollo-link-http';
import * as express from 'express';
import fetch from 'node-fetch';
import { AddressInfo } from 'net';
import { execute } from 'apollo-link';
export { toPromise } from 'apollo-link';
import { ApolloServer } from './';
export const startTestServer = async (server: ApolloServer) => {
@JakeDawkins
JakeDawkins / graphql-enum-test.js
Created July 13, 2018 22:50
testing default enum errors
const {
graphql,
GraphQLEnumType,
GraphQLType,
GraphQLSchema,
GraphQLObjectType,
GraphQLBoolean,
} = require('graphql');
const { gql } = require('graphql-tag');
it('should delete and give visual feedback', async () => {
const deleteDog = { name: 'Buck', breed: 'Poodle', id: 1 };
const mocks = [
{
request: {
query: DELETE_DOG_MUTATION,
variables: { name: 'Buck' },
},
result: { data: { deleteDog } },
},
it('should render loading state initially', () => {
const deleteDog = { name: 'Buck', breed: 'Poodle', id: 1 };
const mocks = [
{
request: {
query: DELETE_DOG_MUTATION,
variables: { name: 'Buck' },
},
result: { data: { deleteDog } },
},
import DeleteButton, { DELETE_DOG_MUTATION } from './delete-dog';
it('should render without error', () => {
renderer.create(
<MockedProvider mocks={[]}>
<DeleteButton />
</MockedProvider>,
);
});
export const DELETE_DOG_MUTATION = gql`
mutation deleteDog($name: String!) {
deleteDog(name: $name) {
id
name
breed
}
}
`;
it('should show error UI', async () => {
const dogMock = {
request: {
query: GET_DOG_QUERY,
variables: { name: 'Buck' },
},
error: new Error('aw shucks'),
};
const component = renderer.create(
const wait = require('waait');
it('should render dog', async () => {
const dogMock = {
request: {
query: GET_DOG_QUERY,
variables: { name: 'Buck' },
},
result: {
data: { dog: { id: 1, name: 'Buck', breed: 'poodle' } },