Skip to content

Instantly share code, notes, and snippets.

View AdamBrodzinski's full-sized avatar

Adam Brodzinski AdamBrodzinski

View GitHub Profile
EvenOrOdd = React.createClass({
propTypes: {
number: React.PropTypes.number.isRequired
},
isEven(num) {
return num % 2 === 0;
},
render() {
describe("EvenOrOdd Component", function() {
var defProps, renderWithProps, component, el, $el;
beforeEach(function() {
defProps = {
number: 2
};
renderWithProps = function(props) {
component = renderComponent(EvenOrOdd, props);
el = React.findDOMNode(component);
TestUtils = React.addons.TestUtils;
Simulate = TestUtils.Simulate;
// returns rendered react component
renderComponent = function (comp, props) {
return TestUtils.renderIntoDocument(
React.createElement(comp, props)
);
};
@AdamBrodzinski
AdamBrodzinski / EvenOrOdd_10_spec.js
Last active August 29, 2015 14:25
Medium React Meteor Testing Tutorial
describe("EvenOrOdd Component", function() {
var defProps, renderWithProps, component, el, $el;
beforeEach(function() {
defProps = {
number: 2
};
renderWithProps = function(props) {
component = renderComponent(EvenOrOdd, props);
el = React.findDOMNode(component);
@AdamBrodzinski
AdamBrodzinski / karma.config.js
Last active February 21, 2016 18:00
Karma React Setup (drop these in /tests/karma/ )
module.exports = function(config) {
config.set({
basePath: '../../',
frameworks: ['jasmine', 'jquery-2.1.0'],
plugins: [
'karma-babel-preprocessor',
'karma-jquery',
'karma-jasmine',
'karma-mocha-reporter',
],
/* Copyright (C) 2012-2014 Kurt Milam - http://xioup.com | Source: https://gist.github.com/1868955
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TO
@AdamBrodzinski
AdamBrodzinski / post_model.js
Created December 8, 2014 01:09
Meteor Model
Post = {
create: function(data, callback) {
return Meteor.call('Post.create', data, callback);
},
update: function(docId, data, callback) {
return Meteor.call('Post.update', docId, data, callback);
},
destroy: function(docId, callback) {
@AdamBrodzinski
AdamBrodzinski / example.js
Last active August 29, 2015 14:10
shows data flow using models, controllers, views, and view controllers
// globals in /both/lib/namespaces.js
db = {};
PostsController = {};
Post = {};
// use iron router controllers with custom namespace
// in /both/controllers/posts.js
//
// render a page to create a new post
@AdamBrodzinski
AdamBrodzinski / gist:8562723
Created January 22, 2014 17:08
Vanilla Bling
var $ = document.querySelectorAll.bind(document);
Element.prototype.on = Element.prototype.addEventListener;
$('#somelink')[0].on('touchstart', handleTouch);
IronRouter.prototype.mapResource = function(resource){
var router = this;
var _routes = [
{ name: resource, path: '/' + resource, action: 'index' },
{ name: 'show' + resource, path: '/' + resource + '/:id', action: 'show' }
];
_.each(_routes, function(route, index){
router.map(function(){
this.route(route.name, {