Skip to content

Instantly share code, notes, and snippets.

View andrewk's full-sized avatar

Andrew Krespanis andrewk

View GitHub Profile
@andrewk
andrewk / karma.conf.js
Last active August 29, 2015 14:07
Webpack + Jasmine 2 + Flight + Karma (https://github.com/andrewk/webpack-jasmine-flight)
module.exports = function (config) {
'use strict';
config.set({
basePath: '',
preprocessors: {
'assets/tests/**/*.js': ['webpack'], // our specs
'assets/js/**/*.js': ['webpack'], // our components
@andrewk
andrewk / jasmine.md
Last active January 3, 2018 21:49
Jasmine 2.0 quick reference

Spies

Create a spy

// "bare" spy
var spy = jasmine.createSpy('spyName');

// Mock object of spies: spy.next(), spy.current(), etc
@andrewk
andrewk / form-validation.md
Created March 29, 2015 10:08
Good Enoughβ„’ Form Validation in React

Good Enoughβ„’ Form Validation in React

…specifically React 0.13 using ES6 class syntax

Originally I was implementing the validator as a context, but then I got stung by parent context vs owner context. I'll likely return to the context model when React's context implementation is more final (looks like they're moving towards parent context over owner context, which I'd prefer).

Requirements

  • markup must match our existing markup, for UX consistency.
  • inputs are re-usable components with an explicit contract -- they are responsponsible for their error display and any required filtering of their value.
@andrewk
andrewk / es6Intl.js
Created August 11, 2015 03:54
ReactIntl without mixins
import provideIntl from './provideIntl';
import ReactIntl from 'react-intl';
const components = {};
export default components;
// FormattedMessage, FormattedNumber, FormattedRelative, FormattedDate
Object.keys(ReactIntl).forEach(key => {
components[key] = provideIntl(ReactIntl[key]);
});
### Keybase proof
I hereby claim:
* I am andrewk on github.
* I am andrew (https://keybase.io/andrew) on keybase.
* I have a public key ASCxw9Pg4zFREfvoBsCnNQoawhSlSZb5J2z4DsVHbpoSEgo
To claim this, I am signing this object: