Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Sara Lissette LissetteIbnz

🎯
Focusing
View GitHub Profile
View mapper.test.tsx
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 Dec 14, 2020
Alternative switch and mapped object
View spike
<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 Nov 11, 2020
Scripts para comprobar cambios de dependencias npm y ejecutar tareas en base a ello
View post-checkout.sh
#!/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
View make-cancellable.ts
/**
* 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 Mar 27, 2019 — forked from wahengchang/ShareCom.js
Unit test, mocking components
View ShareCom.js
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 Mar 6, 2019 — 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
View Fetch.test.js
// 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() })
View asyncForEach.js
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 Mar 4, 2019
JEST: Configure launch.json File for your test framework
View launch.json
{
"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",
View es6-import-cheat-sheet.md
// 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 Sep 28, 2018
Ejemplo de cómo dividir las rutas de una aplicación VueJs con VueRouter
View home.ts
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,