Skip to content

Instantly share code, notes, and snippets.

View ralfting's full-sized avatar
🏠
Working from home

Ralph Effting ralfting

🏠
Working from home
  • Finbits
  • Palhoça - SC
View GitHub Profile
class EmailInput extends React.Component<Props, State> {
state = {
emailList: [],
inputValue: '',
}
setValues = (value: string) => {
let v = value;
if (v.length > 1 && (v.slice(-1) === ',' || v.slice(-1) === ' ')) {
let list = [...this.state.emailList, v.slice(0, -1)];
import data from './USCities.js';
const autoCompletejs = new autoComplete({
data: {
src: () => {
console.log(data)
return data;
},
key: ["city"],
cache: false
@ralfting
ralfting / index.js
Last active September 17, 2019 21:39
const arr = [1,2,3,4];
let newArr = [];
const fetchMock = (item) =>
new Promise(resolve => setTimeout(() => resolve(item), 500));
function someFunc() {
[1,2,3,4].forEach(async (item) => {
const result = await fetchMock(item);
newArr.push(result);
it 'creates claim with current user data prefilled' do
click_link('Claim', match: :first)
click_on 'Submit'
expect(page).to have_current_path(listing_path(@new_listing))
.and(have_text(I18n.t('claims.create.success')))
.and(not_have_link('Claim', href: new_listing_claim_path(@new_listing)))
end
debounce.mockImplementation((cb) => () => cb());
onChange = async ({ target: { value } }: SyntheticEvent<HTMLInputElement>): Promise<void> => {
if (value === this.props.value) return;
const { executeMutation, cardId, id: fieldId } = this.props;
const mutationVars = { variables: { cardId, fieldId, value } };
if(this.state.lastUpdate) this.state.lastUpdate.cancel();
const TIME_DEBOUNCE = 500;
const debounced = debounce(async () => {
try {
@ralfting
ralfting / Radio.jsx
Last active September 6, 2019 19:42
debounce = (): Promise<void> => {
const TIME = 3000;
return new Promise((resolve) => {
setTimeout(resolve, TIME);
})
}
const renderMap = {
DueDateField: component =>
withClickOutside(component, function(event) {
return !event.target.closest('.tether-element');
}),
};
const renderMap = {
DueDateField: (component) => withClickOutside(component, function(event) {
return !event.target.closest('.tether-element');
}),
}
import React from 'react';
import { render } from '@testing-library/react'
import withClickOutsideText from '../withClickOutsideText';
describe('withClickOutisdeText', () => {
it('create a wrapper component', () => {
const MockInput = () => withClickOutsideText(<input />);
const { getByTestId, debug } = render(MockInput);