Skip to content

Instantly share code, notes, and snippets.

View mieradi's full-sized avatar

Michael Ieradi mieradi

  • ottawa
View GitHub Profile
describe('Dashboard tests', () => {
test('Renders dashboard without', async () => {
server.use(getDashboardDataMock(); // first res
const { getByTestId } = render(<Dashboard />);
await waitFor(() => {
expect(getByTestId(/dashboard-trips/i)).toBeNull();
});
});
test('Renders dashboard with trips', async () => {
const { getByText, getAllByTestId } = render(<Dashboard />);
// Example usage
const idArray = [
{ id: 1, title: "My First Title", body: "My first body text" },
{ id: 2, title: "My Second Title", body: "My second body text" },
{ id: 3, title: "My Third Title", body: "My third body text" },
];
const data = filterArrayOfObjectsByKey(idArray,'id', event.currentTarget.id, myData);
// pretend we are using React state
/**
* @name mediaQuery
* @desc function to express media queries
* @param {string} size the size in which to invoke media query, represented in px
* @param {string} condition the condition in which to invoke media query. default is 'min'
* @returns returns desc
* @note the func param is to handle dynamic styles rendered by js rendered by a function
*/
import { css } from 'styled-components'
@mieradi
mieradi / svg.tsx
Last active November 18, 2020 20:01
Reusable SVG component for React, Typescriptm and Styled Components
import React from 'react';
import styled from 'styled-components';
// create a base meta data component
export const SVGBase = styled.svg.attrs({
version: '1.1',
xmlns: 'http://www.w3.org/2000/svg',
xmlnsXlink: 'http://www.w3.org/1999/xlink',
ariaHidden: 'true',
@mieradi
mieradi / index.js
Last active April 17, 2020 15:00
Plain Js Form Validation
/**
* @name CU Form Validation
* @desc validate form inputs utilizing functions from validator.js
* @see https://github.com/validatorjs/validator.js
* @author Michael Ieradi
* @version 1.0.0
*
* @overview
* @func handleValidateOnKeypress()
* @description validate inputs, by attribute, on keypress
@mieradi
mieradi / Simple React title component
Created January 4, 2020 16:18
Simple and helpful title component
const Title = props => {
switch (true) {
case props.h2:
return <h2>{props.title}</h2>;
case props.h3:
return <h3>{props.title}</h3>;
case props.h4:
return <h4>{props.title}</h4>;