Skip to content

Instantly share code, notes, and snippets.

class Component extends React.Components {
onClick() {
}
render() {
return <a href="" onClick={onClick}></a>
}
}
// test
class KataGroups extends React.Component {
render() {
return <div id="layout" className="content pure-g">
<div id="nav" className="pure-u">
<a href="#" className="nav-menu-button">Menu</a>
<div className="nav-inner">
<div className="pure-menu">
<ul className="pure-menu-list">
<li className="pure-menu-heading">Kata groups</li>
it('prints x into a string using ${x}', function() {
var x = 42;
assert.equal(`x=${x}`, 'x=' + x);
});
/**
* Since onLoad doesn't bubble OR capture on the top level in IE8, we need to
* capture it on the <img> element itself. There are lots of hacks we could do
* to accomplish this, but the most reliable is to make <img> a composite
* component and use `componentDidMount` to attach the event handlers.
*/
var ReactDOMImg = ReactClass.createClass({
displayName: 'ReactDOMImg',
tagName: 'IMG',
import {Some} from './some'
var assert = require('assert');
describe('something', () => {
it('that should work', () => {
assert.equal(new Some().method(), 'works');
});
});
var sinon = require('sinon');
beforeEach(function() {
this.sinon = sinon.sandbox.create();
});
afterEach(function(){
this.sinon.restore();
});

ECMAScript 6 has classes built-in. It is a shorter notation for the well-known prototype approach.

class Kata {
  constructor(name) {
    // initialize instance properties in the constructor
    this.name = name;
  }
  // instance method
const isThree = num => num === 3;
const containsThree = arr => !!arr.find(item => item === 3);
it('testMe must be false', function() {
assert.equal(this.testMe, false); // passes
});
beforeEach(function() {
this.testMe = false;
});
it('testMe must be false', () => {
assert.equal(this.testMe, false); // fails
});