Skip to content

Instantly share code, notes, and snippets.

View cdoremus's full-sized avatar

Craig Doremus cdoremus

View GitHub Profile
@cdoremus
cdoremus / AllComponents.test.ts
Created May 26, 2022 03:49 — forked from coryhouse/AllComponents.test.ts
Enforce tests exist for each component
// This file assures that a Jest test file and Cypress test file exists for each component.
import path from "path";
import fs from "fs";
function getFiles(filepath: string) {
return fs.readdirSync(filepath).filter(function (file) {
return fs.statSync(path.join(filepath, file)).isFile();
});
}
@cdoremus
cdoremus / dispatching-action-creators.js
Created June 13, 2017 19:17 — forked from markerikson/dispatching-action-creators.js
Dispatching action creators comparison
// approach 1: define action object in the component
this.props.dispatch({
type : "EDIT_ITEM_ATTRIBUTES",
payload : {
item : {itemID, itemType},
newAttributes : newValue,
}
});
// approach 2: use an action creator function
@cdoremus
cdoremus / dispatching-action-creators.js
Created June 13, 2017 19:17 — forked from markerikson/dispatching-action-creators.js
Dispatching action creators comparison
// approach 1: define action object in the component
this.props.dispatch({
type : "EDIT_ITEM_ATTRIBUTES",
payload : {
item : {itemID, itemType},
newAttributes : newValue,
}
});
// approach 2: use an action creator function
import {action1, action2} from "myActions";
import {bindActionCreators} from "redux";
const mapDispatchToProps(dispatch) => {
return {
manuallyBoundAction : (...args) => dispatch(action1(...args)),
autoBoundAction : bindActionCreators(action2, dispatch),
multipleActionsTogether : bindActionCreators({action1, action2}, dispatch)
}
};
@cdoremus
cdoremus / webdriverjs_localstorage.js
Created March 18, 2017 22:13 — forked from remarkablemark/webdriverjs_localstorage.js
Get and set localStorage with WebDriverJS `executeScript` and `executeAsyncScript`.
'use strict';
/**
* Module dependencies.
*/
const webdriver = require('selenium-webdriver');
/**
* Build driver.
*/
@cdoremus
cdoremus / app-1.spec.ts
Created October 17, 2016 15:07 — forked from wkwiatek/app-1.spec.ts
Angular 2 test snippets for Angular final version. Codebase for https://developers.livechatinc.com/blog/category/programming/angular-2/
// App
import { Component } from '@angular/core';
@Component({
selector: 'app',
template: '<span>{{ sayHello() }}</span>',
})
export class App {
public name: string = 'John';