Skip to content

Instantly share code, notes, and snippets.

Avatar

bessington bessfernandez

  • seattle, wa
View GitHub Profile
@bessfernandez
bessfernandez / api.spec.tsx
Created May 21, 2019
Jest / Nock tests for API wrapper
View api.spec.tsx
// Tests for API wrapper: https://gist.github.com/bessfernandez/4ead80f8f1b7e6f2db8c799bbc849794
// Likely can be improved
/**
* @jest-environment node
*/
import * as nock from 'nock';
import request, { client } from './api';
describe('API tests', () => {
@bessfernandez
bessfernandez / axios-wrapper.tsx
Last active Jun 24, 2022
A lightweight wrapper around axios with TS and async/await
View axios-wrapper.tsx
// A wrapper around axios with TS and async/await
// code below would be it's own .tsx file:
/* eslint-disable no-console */
import axios from 'axios';
const apiRoot = 'http://localhost:3000/';
/**
* Create an Axios Client with baseURL as default
View dom-search.js
var root = document.getElementById('root'),
domSearch = function (root, className) {
var stack = [root],
foundNodes = [];
while (stack.length > 0) {
var nodeToCheck = stack.pop();
View just-the-commands-man.md

Adding Storybook HTML

  1. In the directory of your choosing run the following to pull down and install Storybook:

     npx -p @storybook/cli sb init --type html
    
  2. After install is done kick it off (should open in localhost:6006):

     npm run storybook
    
@bessfernandez
bessfernandez / setting-up-html-storybook-app.md
Last active Nov 23, 2022
How to setup a simple Storybook HTML demo app
View setting-up-html-storybook-app.md

icon-storybook-default

Storybook for HTML

Storybook is all about writing stories. A story usually contains a single state of one component, almost like a visual test case.

Typically you see Storybook used for React or other frameworks, but the library has recently introduced the option to use HTML for your Storybook projects. As a prototyping tool or playground this is great! No larger scale knowledge of other frameworks needed.

Install Storybook HTML

View palindrome-fun.js
// Just a fun experiment at testing palindromes by division
// test if a string is a palindrome by dividing length of string and looking at left and right
function isPalindromeByDivision(str) {
if (!str) {
return;
}
let result;
// clean up string - remove spaces and enforce casing
View slate-doc.json
{
"object": "value",
"document": {
"object": "document",
"data": {},
"nodes": [
{
"object": "block",
"type": "heading-three",
"isVoid": false,
View empty-slate-doc.json
{
"document": {
"nodes": [
{
"object": "block",
"type": "paragraph",
"nodes": [
{
"object": "text",
"leaves": [