Skip to content

Instantly share code, notes, and snippets.

expect(response.data.headline).toEqual(‘Document #12–1332–11’);
expect(response.data.address.city).toEqual(‘Berlin’);
expect(response.data[0].line[0].total).toEqual(101);
expect(response.data[0].line[1].total).toEqual(102);
expect(response.data[0].line[2].total).toEqual(103);
expect(response.data[0].line[3].total).toEqual(104);
expect(response.data[1].line[0].total).toEqual(105);
expect(response.data[1].line[1].total).toEqual(106);
expect(response.data[1].line[2].total).toEqual(107);
expect(response.data[1].line[3].total).toEqual(108);
@alexbeletsky
alexbeletsky / get_invoices_html.js
Created January 19, 2018 15:39
get_invoices_html.js
/* eslint prefer-arrow-callback: 0 */
import expect from 'expect';
import moment from 'moment';
import timekeeper from 'timekeeper';
import beautify from 'js-beautify';
import * as apiUtils from '../../../helpers/api';
import * as serverUtils from '../../../helpers/server';
import * as mongoUtils from '../../../helpers/mongo';
export function trackable(action, event, properties = {}) {
const analytics = {
eventType: event,
eventPayload: properties
};
return { ...action, meta: { analytics } };
}
import constants from '../../constants';
export function loadedDashboardState(website, status, news, revenues) {
return trackable({
type: constants.DASHBOARD_STATE_LOADED,
payload: { website, status, news, revenues }
},
'Dashboard opened', // <- event name
{ name: website.name } // <- additional event data
);
import { createStore, applyMiddleware } from 'redux';
import { createAnalytics } from '../middleware';
const middlewares = [
thunk,
createLogger(),
createAnalytics({ host: 'ANALYTICS_HOST', token: 'ANALYTICS_TOKEN' })
];
const enchancer = applyMiddleware(...middlewares);
import { client } from '../analytics';
const handleAction = (store, next, action, options) => {
if (!action.meta || !action.meta.analytics) {
return next(action);
}
const { eventType, eventPayload } = action.meta.analytics;
client(options).track(eventType, eventPayload);
import { createConstants } from '../utils';
const constants = createConstants(
// account actions
'ACCOUNT_FORM_RESET',
'ACCOUNT_FORM_CHANGE',
'ACCOUNT_FORM_ERRORS',
'ACCOUNT_FORM_ERRORS_CLEAN',
'ACCOUNT_ACCESS_TOKEN_FETCHING',
'ACCOUNT_ACCESS_TOKEN_FETCHED',
export function composeComponents(component, wrappers = []) {
return wrappers.reduce((c, wrapper) => wrapper(c), component);
}
const CheckedWelcome = composeComponents(
Welcome,
[
(c) => checkBoarded(c, { withValue: true, redirectTo: '/app/dashboard' }),
(c) => requiresAuth(c)
]
);
const CheckApp = composeComponents(
App,
const routes = (
<Route path="">
<Route path="/signup" component={SignUp} />
<Route path="/signin" component={SignIn} />
// applied here..
<Route path="/welcome-on-board" component={checkBoarded(Welcome, { withValue: true, redirectTo: '/app/dashboard'}) } />
<Route path="/forgot-password" component={ForgotPassword} />
<Route path="/signout" component={SignOut} />