Skip to content

Instantly share code, notes, and snippets.

View junibrosas's full-sized avatar
🎯
Create! create! create!

Juni Brosas junibrosas

🎯
Create! create! create!
View GitHub Profile
@junibrosas
junibrosas / ComponentTest.tsx
Last active October 18, 2017 01:06
Compilation of snippets for a testing React components.
import * as React from 'react';
import * as sinon from 'Sinon';
import { expect, assert } from 'chai';
import { mount, render, shallow } from 'enzyme';
import { ModalComponent } from './path/of/my/modal/component';
import * as Button from 'react-bootstrap/lib/Button';
import * as ModalFooter from 'react-bootstrap/lib/ModalFooter';
import * as ModalBody from 'react-bootstrap/lib/ModalBody';
import * as Modal from 'react-bootstrap/lib/Modal';
@junibrosas
junibrosas / ComponentReducerTest.tsx
Last active October 14, 2017 07:18
Compilation of snippets for testing reducers in React with Redux.
import { IState } from './types';
import { MyReducer } from './path/to/my/reducer';
import { expect, assert } from 'chai';
describe("DashBoardTodoListStateReducer", () =>
{
var defaultState:IState
beforeEach(() => {
defaultState = MyReducer(undefined, undefined);
@junibrosas
junibrosas / ComponentActionTests.tsx
Last active December 9, 2017 11:49
Compilation of snippets for testing Redux actions.
import * as React from 'react';
import { expect, assert } from 'chai';
import { mount, render, shallow } from 'enzyme';
import * as sinon from 'Sinon';
import { AttendanceActionCreators } from './path/to/actions';
import { AttendanceReducer } from './path/to/reducer';
import { IAttendState } from './path/to/types';
import { Service } from './path/to/service';
describe('Action Test', () =>
@junibrosas
junibrosas / typescriptreact.json
Last active January 31, 2018 11:46
Typescript React snippet for Visual Studio Code
{
"RI":{
"prefix":"ri",
"body":["import * as React from 'react';",""],
"description":"import * as React from 'react';"
},
"RC": {
"prefix": "rc",
"body": ["export interface I${Component}State { }",
@junibrosas
junibrosas / email.directive.ts
Created March 5, 2018 09:34
Angular 5 Registration Form using FormsModule
import {
ReactiveFormsModule,
NG_VALIDATORS,
FormsModule,
FormGroup,
FormControl,
ValidatorFn,
Validator
} from '@angular/forms';
import { Directive } from '@angular/core';
@junibrosas
junibrosas / angularjs-bare-component.spec.js
Last active February 5, 2019 05:49
AngularJS unit testing snippet compilation
// This is only a code snippet and should only provide a guide of testing scenarios.
describe('rmaLeasingLocationAwards', () => {
let $q;
let $componentController;
let $rootScope;
let controller;
beforeEach(() => {
angular.mock.module('RateMyAgent.Profiles.Locations.Leasing');
@junibrosas
junibrosas / contactBar.component.js
Last active January 9, 2019 09:40
Sample AngularJS Component
import { ContactBarController } from './contactBar.controller';
angular.module('RateMyAgent.Common').component('rmaContactBar', {
templateUrl: '/templates/_common/contact-bar/contactBar.html',
bindings: {
agent: '<',
buttonLocation: '<'
},
controllerAs: '$ctrl',
controller: ContactBarController
@junibrosas
junibrosas / node-question.js
Last active February 5, 2019 05:47
Gibberish Snippets
// match regex yes
rl.question('Are you sure you want to download reference pictures? (y(es))', async (answer) => {
if (answer.match(/^y(es)?$/i)) {
await downloadNewRefPics(newRefPicsList);
}
rl.close();
});
@junibrosas
junibrosas / timeout-http.js
Created February 5, 2019 05:57
These are snippet compilation about scenarios using RxJS
import { throwError as observableThrowError, from as observableFrom, Observable, TimeoutError, of } from 'rxjs';
import { mergeMap, catchError, timeout, retryWhen, concatMap } from 'rxjs/operators';
import { Injectable } from '@angular/core';
import { HttpClient, HttpParams } from '@angular/common/http';
import { EntityService } from '../entity/entity.service';
import { UserService } from '../../promoter/legacy/_common/services/user-service/user.service';
import rmaProperties from '../../../rmaProperties';
@junibrosas
junibrosas / react-redux-typings.ts
Last active March 26, 2019 10:54
Proper typings of react-redux connected components
import * as React from 'react'
import * as Redux from 'redux'
import { MyReduxState } from './my-root-reducer.ts'
export interface OwnProps {
propFromParent: number
}
interface StateProps {