Skip to content

Instantly share code, notes, and snippets.

Avatar
👨‍💻
Technologying

Stephen Rhodes MrRhodes

👨‍💻
Technologying
View GitHub Profile
@MrRhodes
MrRhodes / test.js
Created Aug 2, 2017
Should not find conditionally rendered child?
View test.js
import React from 'react';
import { shallow } from 'enzyme';
class ConditionalParent extends React.Component {
render() {
return !!this.props.visible && (<div>{this.props.children}</div>);
}
}
class Child extends React.Component {
View gist:6495131049bb7d76120138564046f73e
const initialState = new Immutable.Map({
email: '',
password: '',
isLoggingIn: false,
isLoggedIn: false,
error: null
});
export default function user(state = initialState, action) {
switch (action.type) {
View testing.1.js
describe("user api tests", function() {
it("should add a new user to the database", function(done) {
api.put('/user/123')
.then(response => {
assert.equal(response.statusCode, 201)
View index.html
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-2.1.1.min.js"></script>
<meta charset="utf-8">
<title>JS Bin</title>
<style id="jsbin-css">
table {
border-collapse:collapse;
}
@MrRhodes
MrRhodes / gist:5f3d60c2c26148b514aa
Created Jan 8, 2015
Array filter chaining for a basic "rules" implementation.... (not run this code, so might have errors, but you get the idea)
View gist:5f3d60c2c26148b514aa
var items = [
...
];
var satisfied = items
.filter(condition1(5))
.filter(condition2('camel'))
.filter(condition3)
function condition1(something) {
@MrRhodes
MrRhodes / gist:72181ea03bf1ed94f37a
Created Dec 16, 2014
Trying to write a simple next/last day thingy with Moment.
View gist:72181ea03bf1ed94f37a
var moment = require('moment');
function Datey() {
this.date = moment();
this.modifier = 1;
return this;
}
Datey.prototype.last = function() {
this.modifier = -1;