Skip to content

Instantly share code, notes, and snippets.

View ollelauribostrom's full-sized avatar

Olle Lauri Boström ollelauribostrom

View GitHub Profile
yarn add jest-enzyme --dev
# OR
npm install jest-enzyme --save-dev
● Tests for Box component › should render
expect(received).toEqual(expected)
Expected value to equal:
true
Received:
false
● Tests for Box component › should render
Expected "[empty set]" to exist.
● Tests for Box component › should apply custom class name if provided
Expected <div> to have className of ".custom-red-box" but instead found "box"
Found node output: <div className="box" />
import * as React from 'react';
import { shallow } from 'enzyme';
import { Box } from './Box';
describe('Tests for Box component', () => {
it('should render', () => {
const box = shallow(<Box />);
expect(box.find('.box')).toExist();
});
it('should apply custom class name if provided', () => {
import * as React from 'react';
import { shallow } from 'enzyme';
import { Box } from './Box';
describe('Tests for Box component', () => {
it('should render', () => {
const box = shallow(<Box />);
expect(box.find('.box').exists()).toEqual(true);
});
it('should apply custom class name if provided', () => {
import * as React from 'react';
export function Box({ customClassName, label }) {
return (
<div className={`box ${customClassName}`}>
{label}
</div>
);
}
@ollelauribostrom
ollelauribostrom / load.lisp
Created February 25, 2018 00:43
Quicklisp: Load Local Project
;; SRC: https://www.darkchestnut.com/2016/quicklisp-load-personal-projects-from-arbitrary-locations/
(pushnew (truename "/projects/app/") ql:*local-project-directories* )
(ql:register-local-projects)
(ql:quickload :app)
@ollelauribostrom
ollelauribostrom / docker.sh
Created February 8, 2018 16:21
Docker: Remove All Images and Containers
# @https://davidwalsh.name/docker-remove-all-images-containers
# Delete every Docker containers
# Must be run first because images are attached to containers
docker rm -f $(docker ps -a -q)
# Delete every Docker image
docker rmi -f $(docker images -q)
@ollelauribostrom
ollelauribostrom / listen.js
Last active January 28, 2018 02:34
Play MP3-stream from Node.js
import request from 'request';
import Speaker from 'speaker';
import lame from 'lame';
const speaker = new Speaker({
channels: 2,
bitDepth: 16,
sampleRate: 44100,
mode: lame.STEREO,
});
@ollelauribostrom
ollelauribostrom / npm-link-permission-denied-after-build-babel.sh
Last active September 23, 2023 12:29
Simple fix to permission denied error when using babel to transpile ES6 code during development of npm package / node module / cli