This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// a highly simplified version of a spy which counts total call | |
var spy = function(object, property){ | |
var origFn = object[property]; | |
var spyFn = function(){ | |
spyFn.callCount++; | |
return origin.apply(object, arguments); | |
} | |
spyFn.callCount = 0; | |
object[property] = spyFn; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//================================== | |
// Functional classes | |
// Define methods inside the object constructing function | |
var makeAnimal = function(name){ | |
var obj = {}; | |
obj.name = name; | |
var privateVar = 'you can see me'; | |
obj.speak = function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//================================== | |
// Functional classes | |
// Define methods inside the object constructing function | |
var makeAnimal = function(name){ | |
var obj = {}; | |
obj.name = name; | |
var privateVar = ' you can see me'; | |
obj.speak = function () { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var player = function (type) { | |
return function(song){ | |
console.log('I can play '+song+' on '+ type); | |
} | |
} | |
var guitarPlayer = player('guitar'); | |
guitarPlayer('Country Road'); | |
var pianoPlayer = player('piano'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import renderer from 'react-test-renderer'; | |
//children mock need to be defined before parent module import | |
jest.mock('react-bootstrap-table', () => { | |
return { | |
BootstrapTable: 'BootstrapTable', | |
TableHeaderColumn: 'TableHeaderColumn', | |
}; | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import react from 'react'; | |
class Person extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
name: '' | |
}; | |
this.handleChange = this.handleChange.bind(this); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import react from 'react'; | |
class Person extends React.Component { | |
constructor(props) { | |
super(props); | |
this.state = { | |
name: '' | |
}; | |
//there is no need to bind event handlers here :) | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Show hidden characters
{ | |
"extends": ["airbnb", "plugin:flowtype/recommended"], | |
"parserOptions": { | |
"ecmaVersion": 7, | |
"sourceType": "module", | |
"ecmaFeatures": { "jsx": true, "modules": true } | |
}, | |
"parser": "babel-eslint", | |
"env": { | |
"browser": true, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const path = require('path'); | |
module.exports = { | |
devtool: 'cheap-module-eval-source-map', | |
entry: path.join(__dirname, './src/index.js'), | |
output: { | |
path: path.join(__dirname, './dist'), | |
filename: 'main.js' | |
}, | |
devServer: { | |
publicPath: './dist/' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Dynamic name generation | |
const webpack = require('webpack'); | |
const path = require('path'); | |
const HtmlWebpackPlugin = require('html-webpack-plugin'); | |
const CleanWebpackPlugin = require('clean-webpack-plugin'); | |
module.exports = { | |
entry: { main: path.join(__dirname, './src/index.js') }, | |
output: { |
OlderNewer