Skip to content

Instantly share code, notes, and snippets.

View LissetteIbnz's full-sized avatar
:electron:
Focusing

Sara Lissette LissetteIbnz

:electron:
Focusing
View GitHub Profile
describe('Login Mappers test', () => {
describe('mapLoginResponseToUserSession function', () => {
const invalidTestCases = [null, undefined, {}];
it.each(invalidTestCases)(
'given a %s value should return an empty user session',
actual => {
expect(mapLoginResponseToUserSession(actual as any)).toEqual({
userName: '',
token: '',
@LissetteIbnz
LissetteIbnz / spike
Created December 14, 2020 23:06
Alternative switch and mapped object
<body>
<script>
const printResult = (item) => console.log(`Selected option '${item}'.`);
const mappedObject = {
option1: printResult,
option2: printResult,
option3: printResult,
option4: printResult,
option5: printResult,
option6: printResult,
@LissetteIbnz
LissetteIbnz / post-checkout.sh
Created November 11, 2020 09:00
Scripts para comprobar cambios de dependencias npm y ejecutar tareas en base a ello
#!/bin/bash
# Looks for changes to package.json and automates running tasks.
# An adaptation of https://gist.github.com/stefansundin/82051ad2c8565999b914
echo "Check installed dependencies and execute npm install and pod install"
# post-checkout hook - looks for changes to package.json,
# when you change branches, and if found, reinstalls the given packages every
# Exit early if this was only a file checkout, not a branch change ($3 == 1)
[[ $3 == 0 ]] && exit 0
/**
* TypeScript version of @istarkov's cancellable Promise wrapper.
*
* @see https://github.com/facebook/react/issues/5465#issuecomment-157888325
*/
const makeCancelable = <T>(promise: Promise<T>): { promise: Promise<T>; cancel(): void } => {
let hasCanceled = false;
const wrappedPromise = new Promise<T>((resolve, reject) => {
promise.then(
@LissetteIbnz
LissetteIbnz / ShareCom.js
Created March 27, 2019 14:36 — forked from wahengchang/ShareCom.js
Unit test, mocking components
import { InstallCom } from 'installComponent' //installed by npm
import UserCom from './userComponent'
export class ShareCom extends Component {
render() {
return (
<div>
<InstallCom para1='title1'/>
<UserCom para2='title2' />
</div>
@LissetteIbnz
LissetteIbnz / Fetch.test.js
Created March 6, 2019 14:06 — forked from alfonsomunozpomer/Fetch.test.js
How to test a React component that sets its state in componentDidMount with fetch, and how to mock it, in Jest
// https://github.com/alfonsomunozpomer/react-fetch-mock
import React from 'react'
import fetchMock from 'fetch-mock'
import Enzyme from 'enzyme'
import {shallow, mount, render} from 'enzyme'
import Adapter from 'enzyme-adapter-react-16'
Enzyme.configure({ adapter: new Adapter() })
async function asyncForEach(array, callback) {
for (let index = 0; index < array.length; index++) {
await callback(array[index], index, array);
}
}
const start = async () => {
await asyncForEach([1, 2, 3], async (num) => {
await waitFor(50);
console.log(num);
@LissetteIbnz
LissetteIbnz / launch.json
Last active March 4, 2019 09:58
JEST: Configure launch.json File for your test framework
{
"version": "0.2.0",
"configurations": [
{
"type": "node",
"request": "launch",
"name": "Jest All",
"program": "${workspaceFolder}/node_modules/.bin/jest",
"args": ["--runInBand", "--config", "jest.config.js"],
"console": "integratedTerminal",
@LissetteIbnz
LissetteIbnz / es6-import-cheat-sheet.md
Created January 4, 2019 10:38 — forked from samueljseay/es6-import-cheat-sheet.md
ES6 exports / imports cheat sheet
// default exports
export default 42;
export default {};
export default [];
export default (1 + 2);
export default foo;
export default function () {}
export default class {}
export default function foo () {}
@LissetteIbnz
LissetteIbnz / home.ts
Last active September 28, 2018 09:52
Ejemplo de cómo dividir las rutas de una aplicación VueJs con VueRouter
import { RouteConfig } from 'vue-router';
const Home = () => import(/* webpackChunkName: "home" */ '../views/Home.vue');
const About = () => import(/* webpackChunkName: "about" */ '../views/About.vue');
export const HomeRoutes: RouteConfig[] = [
{
path: '/',
name: 'home',
component: Home,