This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function styledComponentWithProps<T, U extends HTMLElement = HTMLElement> | |
(styledFunction: StyledFunction<React.HTMLProps<U>>): StyledFunction<T & React.HTMLProps<U>> { | |
return styledFunction | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React, { useEffect, useMemo } from "react"; | |
import { Socket } from "phoenix"; | |
// A utility to get the JWT token of the user | |
import getUserJWT from "utils/getUserJWT"; | |
// The URL of the socket, example: ws://localhost:4000 | |
import { SOCKET_URL } from "settings/socket"; | |
// A hook that returns the current user authenticated |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import * as dateFnsLocales from 'date-fns/locale'; | |
import { Locale } from 'date-fns'; | |
import i18n from './i18n'; | |
interface Locales { | |
[key: string]: Locale; | |
} | |
const getDateFnsLocale = (): Locale => { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Old test: | |
cy.visit('/email_messages') | |
cy.contains(FROM_EMAIL).click() | |
cy.findByRole('button', { name: 'Associate user' }).click() | |
cy.findByPlaceholderText('Type user name...').type(USER_NAME) | |
cy.findByRole('option', { name: new RegExp(USER_NAME) }).click() | |
cy.findByRole('button', { name: 'Select' }).click() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env zsh | |
# I'm using jq to parse json. I really suggest using it. | |
# I'm using parallel for faster results, you could use xargs or a for loop if you don't have parallel. | |
main() ( | |
set -eux | |
local options="--profile some-profile" | |
local key='id' | |
local table='table' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const spinWheel = useCallback(() => { | |
// Receives the winner prop and search for his position in the spinner bets array | |
const order = [8, 1, 14, 2, 13, 3, 12, 4, 0, 11, 5, 10, 6, 9, 7]; | |
const position = order.indexOf(winner); | |
// Determine position where to land | |
const rows = 12; | |
const card = 80 + 2 * 2; | |
let landingPosition = rows * 15 * card + position * card; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useSelector, useDispatch } from 'react-redux' | |
import { render, fireEvent } from '@testing-library/react'; | |
// It can receive two more parameters, the second one is to specify a factory instead of the jest's automocking feature | |
jest.mock('react-redux') | |
it('should load some items in the component', () => { | |
// Returning a mock data from the store to test the behavior of the component | |
useSelector.mockImplementation((cb) => cb({items: ['Hello World']}) | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const React = require('react'); | |
const reactI18next = require('react-i18next'); | |
/* | |
Also, if you're changing the language, add that mock function before your test suit | |
jest.mock('react-i18next', () => ({ | |
useTranslation: () => ({ | |
t: key => key, | |
i18n: { changeLanguage: jest.fn() }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { render } from '@testing-library/react'; | |
import { ThemeProvider } from 'styled-components'; | |
import { MemoryRouter } from 'react-router-dom'; | |
import theme from '~/styles/theme'; | |
// eslint-disable-next-line | |
function ProvidersWrapper({ children }) { | |
return ( |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const FakeComponent = () => { | |
return ( | |
<AnimatedRoutes exitBeforeEnter initial={false}> | |
<RouteTransition exact path="/some-route"> | |
<NewUsers /> | |
</RouteTransition> | |
<RouteTransition exact path="/yo" > | |
<Users /> | |
</RouteTransition> | |
</AnimatedRoutes> |
NewerOlder