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
describe('Email badge', () => {
it('adds two email', () => {
const { container, getByTestId } = render(<EmailInput setTo={jest.fn()} {...props} />);
container.querySelector('input').value = 'example1@pipefy.com,';
fireEvent.keyUp(container.querySelector('input'), {
key: 'Backspace',
});
container.querySelector('input').value = 'example2@pipefy.com,';
setValues = (v: string): void => {
const lastChar = v.slice(-1);
const isComma = lastChar === ',';
const isSpace = lastChar === ' ';
if (isComma || isSpace) {
const delimiter = /,| /;
const notEmptyText = text => text.length > 0;
const emails = v
.slice(0, -1)
{
"zip_code": 501,
"latitude": 40.922326,
"longitude": -72.637078,
"city": "Holtsville",
"state": "NY",
"county": "Suffolk"
},
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);
})
}