Skip to content

Instantly share code, notes, and snippets.

@cfv1984
cfv1984 / xanthan.js
Created May 31, 2021 18:35
Xanthan: A cute, declarative way to graft methods to specific Sequelize instances behind feature flags
/**
* Xanthan is a cute declarative way to compose different sets of traits onto Sequelize models
*
* It is distributed under the terms of the WTFPL (http://www.wtfpl.net/about/)
*
* Usage:
* const {Sequelize, DataTypes: { TEXT, INTEGER } } = require('sequelize');
* const { getFoo, setFoo } = require('./expandos/foo');
* require('./xanthan')(Sequelize)({
@cfv1984
cfv1984 / URI.js
Last active December 4, 2019 14:57
ES6 URI class that can be used with anything resembling an URL.
const cache = {};
export default class URI
{
constructor(url){
this.url = url
this.parts = {}
}
parse(){
if(this.url in cache){
PASS test/list-all-albums.steps.js
✓ Viewing the Gallery (177ms)
Test Suites: 1 passed, 1 total
Tests: 1 passed, 1 total
Snapshots: 0 total
Time: 0.732s, estimated 1s
Ran all test suites.
Watch Usage: Press w to show more.
const Album = ({photos}) => <Fragment>
{photos.map(photo => <Thumbnail photo={photo} key={photo.id}/>)}
</Fragment>;
// view-a-photo.feature
Feature: View a photo in full size
In order to view an album's photo
As an user
I want to open the first Album and see its contents, then open its first Photo
Scenario: Viewing a single Photo
Given the Gallery component is present
And the first album was selected
When the Photos are visible
Then I want to open a Photo
//view-an-album.feature
Feature: View an album's contents
In order to view an album's contents
As an user
I want to open the first Album and see its contents, then the second one, and have the first one close before
Scenario: Viewing an album's photos
Given the Gallery component is present
And the first album was selected
When album opens
Then I want the Album to keep a list of Photos in it
// list-all-albums.feature
Feature: List all of the site's albumsIn order to check how many albums my site currently has
As an user
I want there to be a Gallery
Scenario: Listing all albums
Given the Gallery component is present
When the page is rendered
Then I want the component to have an Album for each gallery in the site
And I want the Album to hold a Thumbnail for each image in it