Skip to content

Instantly share code, notes, and snippets.

View Jayphen's full-sized avatar
🏠
Working from home

Jayphen Jayphen

🏠
Working from home
View GitHub Profile
@Jayphen
Jayphen / machine.js
Created May 13, 2020 14:50
Generated by XState Viz: https://xstate.js.org/viz
function deriveStatus(){}
const stateMachine = Machine(
{
id: 'package',
initial: 'loading',
context: { packageProduct: null, items: {}, price: {}, error: null },
on: {
UPDATE_ITEM: {
actions: 'updateItems',
target: 'validating',
@Jayphen
Jayphen / whatev.js
Last active July 6, 2021 19:35
Page tracking in Sapper
// stores/location.ts
import { writable, derived } from "svelte/store";
import { beforeUpdate } from "svelte";
export interface LocationStore {
current: Location | undefined;
previous: Location | undefined;
}
@Jayphen
Jayphen / 🙏.spec.js
Created June 24, 2021 15:58
spy on a component but also keep its implementation
// for when you REALLY need to test the props SomeComponent is rendered with (not recommended)
// create a mock that re-implements the default behaviour
// but allows us to spy on the props
jest.mock('components/SomeComponent', () => {
const original = jest.requireActual('components/SomeComponent')
return jest.fn(original.default)
})