Skip to content

Instantly share code, notes, and snippets.

@jedwood
jedwood / sample-test-1.js
Last active July 4, 2016 23:55
API Testing Example - Part 1
describe('Authentication', function() {
it('errors if wrong basic auth', function(done) {
api.get('/blog')
.set('x-api-key', '123myapikey')
.auth('incorrect', 'credentials')
.expect(401, done)
});
it('errors if bad x-api-key header', function(done) {
@jedwood
jedwood / sample-test-2.js
Created April 4, 2013 15:33
API Testing Example - Part 2
describe('/blog', function() {
it('returns blog posts as JSON', function(done) {
api.get('/blog')
.set('x-api-key', '123myapikey')
.auth('correct', 'credentials')
.expect(200)
.expect('Content-Type', /json/)
.end(function(err, res) {
if (err) return done(err);
@jedwood
jedwood / belay-js-example.html
Created February 14, 2014 00:14
Tiny helper for connecting two elements with SVG lines. Assumes jQuery (for now). Original by @johndilworth
<!DOCTYPE html>
<html>
<head>
<title>SVG Lines</title>
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<script src="belay.js"></script>
<link rel="stylesheet" type="text/css" href="http://netdna.bootstrapcdn.com/bootstrap/3.1.1/css/bootstrap.min.css">
<style>
body{
@jedwood
jedwood / _.md
Created May 14, 2014 19:10
ordinal color scales
@jedwood
jedwood / Goog-Apps-Slack-Library.js
Created June 3, 2016 18:36
Google Apps Script Library for interacting with the Slack API (likely outdated, as this was circa 2014)
var token = false;
/**
* Set the token.
*
* @param {string} Slack API token;
*/
function setToken(t){
token = t;
}