Skip to content

Instantly share code, notes, and snippets.

@joelmukuthu
joelmukuthu / keybase.md
Created February 22, 2020 09:42
My keybase

Keybase proof

I hereby claim:

  • I am joelmukuthu on github.
  • I am joelmukuthu (https://keybase.io/joelmukuthu) on keybase.
  • I have a public key ASAZ3ld1hD4tLEj8uyfQiPYoamLddZMDHyxl_A8O_d7cAgo

To claim this, I am signing this object:

@joelmukuthu
joelmukuthu / unexpected-mongoose.js
Created July 5, 2017 07:53
unexpected-mongoose
const { Model, Types: { ObjectId, Document } } = require('mongoose');
module.exports = {
name: 'unexpected-mongan',
installInto: expect => {
expect.use(require('unexpected-set'));
expect.addType({
name: 'MongooseModel',
identify(val) {
import React, { Component } from 'react';
import { createRenderer } from 'react-addons-test-utils';
import unexpected from 'unexpected';
import unexpectedReact from 'unexpected-react';
class Foo extends Component {
constructor(props) {
super(props);
this.state = {
var httpception = require('httpception');
var got = require('got');
var assert = require('assert');
describe('the thing', function () {
before(function() {
httpception({
request: 'GET http://example.com/foobar',
response: {
headers: {
@joelmukuthu
joelmukuthu / sinon.test-with-promises.js
Last active August 8, 2016 09:41
This is a mocha test case demostrating a bug with [sinon.test](http://sinonjs.org/docs/#sinon-test) whereby the sandbox gets restored before a promise-based async test completes.
// sinon version 1.17.5
// Github issue: https://github.com/sinonjs/sinon/issues/1119
var sinon = require('sinon');
describe('sinon.test', function () {
describe('with a promise', function () {
it('does not restore the sandbox until the promise is fulfilled', sinon.test(function () {
var sandbox = this;
return Promise.resolve()
.then(function () {
@joelmukuthu
joelmukuthu / git_aliases
Last active August 9, 2016 08:35
Git aliases that I use
[alias]
hist = log --graph --pretty=format':%C(yellow)%h%Cblue%d%Creset %s %C(white) %an, %ar%Creset'