Skip to content

Instantly share code, notes, and snippets.

@shahab65
shahab65 / array.md
Last active October 14, 2020 03:55

remove from array in returning removed item:

const removeUser = id => {
  const index = users.findIndex((user) => user.id === id)
  
  if (index !== -1) {
    return users.splice(index, 1)[0]
    }
    }
@shahab65
shahab65 / curl.md
Last active July 24, 2019 14:37
curl commands
curl https://0ca6yach5d.execute-api.us-east-1.amazonaws.com/development/account/api/v1/users/ --header "Authorization: Bearer my-token"
yarn add history
import createHistory from 'history/createBrowserHistory';
export const history = createHistory();
<Router history={history}>

above code has warning so I changed it to this:

import { createBrowserHistory } from 'history';
export const history = createBrowserHistory();

unstyled list:

    list-style-type: none;
test("returns undefined by default", () => {
  const mock = jest.fn();

  let result = mock("foo");

  expect(result).toBeUndefined();
  expect(mock).toHaveBeenCalled();
  expect(mock).toHaveBeenCalledTimes(1);
 expect(mock).toHaveBeenCalledWith("foo");
@shahab65
shahab65 / cypress-cheatsheet.md
Last active April 5, 2019 17:41
learning cypress

cypress

should

cy.url().should('include', 'login')
cy.get('input[name=email]').type(email);