Skip to content

Instantly share code, notes, and snippets.

View AlejoDev95's full-sized avatar

Julian Alejandro Sanchez Burbano AlejoDev95

View GitHub Profile
@AlejoDev95
AlejoDev95 / ejercicios.md
Created September 18, 2023 13:05
Ejercicios logica

Ejercicios de logica

Creación de variables

  1. Crea una variable llamada nombre y asígnale tu nombre.
  2. Declara una variable edad y asígnale tu edad.
  3. Crea una variable estaLloviendo y asígnale un valor booleano que represente si está lloviendo o no.
  4. Declara una variable num1 y otra num2, y luego suma estos dos números y almacena el resultado en una tercera variable llamada suma.
  5. Crea una variable frutas como un array que contenga tres nombres de frutas.
@AlejoDev95
AlejoDev95 / form.ts
Created May 27, 2023 13:00
Conjunto de funciones que nos permiten asignar un valor a los elementos de un input
import { queryById, query } from './finder';
import { ComponentFixture } from '@angular/core/testing';
export function setInputValue<T>(
fixture: ComponentFixture<T>,
selector: string,
value: string,
withTestById = false
) {
const inputDe = withTestById ? queryById(fixture, selector) : query(fixture, selector);
@AlejoDev95
AlejoDev95 / click.ts
Created May 27, 2023 12:58
Conjunto de funciones que nos van a pemitir simular un click en nuestras pruebas unitarias
import { ComponentFixture } from '@angular/core/testing';
import { queryByTestId, query } from './finder';
export function clickEvent<T>(
fixture: ComponentFixture<T>,
selector: string,
withTestId = false,
eventName = 'click',
event: unknown = null
) {
@AlejoDev95
AlejoDev95 / async-data.ts
Created May 27, 2023 12:55
Grupo de funciones que nos van a permitir trabajar con procesos asincronos en nuestras pruebas unitarias
import { defer, of } from 'rxjs';
export function asyncData<T>(data: T) {
return defer(() => Promise.resolve(data));
}
export function asyncError(error: unknown) {
return defer(() => Promise.reject(error));
}
@AlejoDev95
AlejoDev95 / finder.ts
Last active June 3, 2023 11:51
Funciones que nos permiten buscar un elemento en nuestros unit test
import { By } from '@angular/platform-browser';
import { ComponentFixture } from '@angular/core/testing';
import { Type, DebugElement } from '@angular/core';
export function query<T>(
fixture: ComponentFixture<T>,
selector: string,
canReturnError = true
) {
const elementDe = fixture.debugElement.query(By.css(selector));