Skip to content

Instantly share code, notes, and snippets.

View TracyNgot's full-sized avatar
🏠
Working from home

Yolaine TracyNgot

🏠
Working from home
View GitHub Profile
@TracyNgot
TracyNgot / query-builder.test.ts
Created June 19, 2020 21:04
FaunaDB Query builder + test
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);
@TracyNgot
TracyNgot / unicorn.epic.test.ts
Last active August 8, 2019 21:44
Epic unit tests with TypeScript, Redux, RxJS 6 and Jest
// 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 / mock.ts
Created November 22, 2018 21:03
Mock Server With ExpressJS, Typescript and JSON
interface Mock {
pathname: string;
method: string;
status: number;
responseBody: JSON;
}
class MockRoutes {
mockRoutes: Mock[] = [];
@TracyNgot
TracyNgot / mock-route.ts
Last active November 22, 2018 14:09
Mock Server With ExpressJS, TypeScript for your API
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 / unicorn.action.ts
Created September 20, 2018 23:24
Action example with TypeScript
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 / unicorn.epic.ts
Last active September 21, 2018 00:14
Epic example with TypeScript, Redux, RxJS 6
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),