Skip to content

Instantly share code, notes, and snippets.

@fab9
fab9 / hello.html
Last active August 29, 2015 19:18
React component: A textarea counter.
<!DOCTYPE html>
<html>
<head>
<title>hello React</title>
<meta charset="utf-8">
</head>
<body>
<div id="app">
<!-- my app renders here -->
</div>
// ButtonSpec.js
import React from 'react';
import ReactTestUtils from 'react/lib/ReactTestUtils';
import Button from '../src/Button';
describe('Button', function () {
it('Should output a button', function () {
let instance = ReactTestUtils.renderIntoDocument(
<Button>
Title
import React, {PropTypes} from 'react'
import { Link } from 'react-router'
class Button extends React.Component {
render() {
const button = this.props;
return(
<button className="btn btn-primary">
{button.text}
@fab9
fab9 / protractor.conf.js
Last active August 29, 2015 14:21
Protractor config file
exports.config = {
framework: 'mocha',
specs: [
'test/e2e/**/*.spec.js'
],
mochaOpts: {
enableTimeouts: false // Necessary to avoid timeout bugs with Mocha that sometimes happen while using Protractor. May already be resolved.
}
}
@fab9
fab9 / cheese_finder_test.rb
Last active August 29, 2015 14:21
Example of a test ported from the Selenium IDE to Ruby
# convert search test to use the Test::Unit framework
require 'rubygems'
require 'selenium-webdriver'
require 'test/unit' # pull in the gem
class CheeseFinderTests < Test::Unit::TestCase # declare new class
def test_find_some_cheese # create new method that has all the test code
selenium = Selenium::WebDriver.for(:firefox)
@fab9
fab9 / .bowerrc
Last active August 29, 2015 14:19 — forked from al-the-x/.bowerrc
{
"scripts": {
"postinstall": "./node_modules/.bin/wiredep -s index.html"
}
}
@fab9
fab9 / 16-col
Created February 5, 2015 20:50
Bootstrap: visualize 16 col
<h2>Test 16 columns</h2>
<div class="row">
<div class="col-md-1 red">Col 1</div>
<div class="col-md-1 red">Col 2</div>
<div class="col-md-1 red">Col 3</div>
<div class="col-md-1 red">Col 4</div>
<div class="col-md-1 red">Col 5</div>
<div class="col-md-1 red">Col 6</div>
<div class="col-md-1 red">Col 7</div>
@fab9
fab9 / controller.js
Last active August 29, 2015 14:13 — forked from al-the-x/controller.js
angular.module('myModule', [ ], function($rootScope){ // equivalent to .config(function($rootScope){ . . . })
$rootScope._ = _; // Make `_` available in Angular Expressions
}).controller('MyController', function(Something){
var saveSomething = this.saveSomething = Something.save();
$scope.$watch('something', _.debounce(saveSomething, 500));
$scope.something = 'some value';
})
; // END myModule
var assert = require('assert');
function test(actual, expected, success){
success = success || 'pass!';
assert.equal(actual, expected);
console.log(success);
}
var assert = require('assert');
function test(actual, expected, success){
success = success || 'pass!';
assert(actual === expected) || console.log(success);
}
/**
* Check Writing