Skip to content

Instantly share code, notes, and snippets.

Avatar
🏠
Working from home

Yolaine TracyNgot

🏠
Working from home
View GitHub Profile
@TracyNgot
TracyNgot / unicorn.epic.test.ts
Last active Aug 8, 2019
Epic unit tests with TypeScript, Redux, RxJS 6 and Jest
View unicorn.epic.test.ts
// src/tests/unicorn/unicorn.epic.test.ts
import { ActionsObservable } from 'redux-observable';
import { of, throwError } from 'rxjs';
import { toArray } from 'rxjs/operators';
import UnicornActions from '../../store/unicorn/unicorn.action';
import UnicornApiService from '../../store/unicorn/unicorn.api.service';
import UnicornEpics from '../../store/unicorn/unicorn.epic';
describe('Unicorn test', () => {
@TracyNgot
TracyNgot / unicorn.epic.ts
Last active Sep 21, 2018
Epic example with TypeScript, Redux, RxJS 6
View unicorn.epic.ts
import { ofType } from 'redux-observable';
import { of } from 'rxjs';
import { catchError, flatMap, map, mergeMap } from 'rxjs/operators';
import UnicornActions from './unicorn.action';
import UnicornApiService from './unicorn.api.service';
export default class UnicornEpics {
public static getUnicorn = (actions$: any) =>
actions$.pipe(
ofType(UnicornActions.Types.GET_UNICORN),
@TracyNgot
TracyNgot / unicorn.action.ts
Created Sep 20, 2018
Action example with TypeScript
View unicorn.action.ts
export default class UnicornActions {
public static Types = {
ERROR: 'UNICORN_ERROR',
GET_UNICORN: 'GET_UNICORN',
LIKE_UNICORN: 'LIKE_UNICORN',
SUCCESS: 'UNICORN_SUCCESS',
UPDATE_UNICORN: 'UPDATE_UNICORN',
}
public static error = (err: any, actionName: string) => ({
@TracyNgot
TracyNgot / mock-route.ts
Last active Nov 22, 2018
Mock Server With ExpressJS, TypeScript for your API
View mock-route.ts
import * as express from 'express';
import mockRoutes from './MockRoutes';
import config from '../config/Config';
import proxy = require('http-proxy-middleware');
class Routes {
public router: express.Router = express.Router();
constructor() {
this.config();
@TracyNgot
TracyNgot / mock.ts
Created Nov 22, 2018
Mock Server With ExpressJS, Typescript and JSON
View mock.ts
interface Mock {
pathname: string;
method: string;
status: number;
responseBody: JSON;
}
class MockRoutes {
mockRoutes: Mock[] = [];
@TracyNgot
TracyNgot / query-builder.test.ts
Created Jun 19, 2020
FaunaDB Query builder + test
View query-builder.test.ts
import { Expr } from 'faunadb';
import QueryBuilder from './query-builder';
describe('QueryBuilder', () => {
it('builds FaunaDB query', () => {
const testCollection = new QueryBuilder<any>('test');
expect(testCollection.create({ test: 'my-test' })).toBeInstanceOf(Expr);
expect(
testCollection.update('id', { test: 'my-test-updated' }),
).toBeInstanceOf(Expr);
You can’t perform that action at this time.