Skip to content

Instantly share code, notes, and snippets.

@maurer2
maurer2 / gist:04733d18f6c399601d04d7dfb2579822
Created April 23, 2024 15:01
PartialMatching in toHaveBeenCalledWith
mySpy.toHaveBeenCalledWith('important', 'important', expect.anything());
@maurer2
maurer2 / gist:04ce44d16fcce9b93009d1e7a77b2e1b
Created April 15, 2024 13:34
More readable "within" query in RTL
const parent = within(screen.getByRole('list', { name: 'test' }));
expect(parent.getByRole('list')).toBeVisible();
expect(parent.getAllByRole('listitem')).toHaveLength(10);
or
const { getByRole, getAllByRole } = within(screen.getByRole('list', { name: 'test' }));
expect(getByRole('list')).toBeVisible();
@maurer2
maurer2 / Google geolocation bounding box format
Last active December 23, 2022 12:52
Google geolocation bounding box format
https://maps.googleapis.com/maps/api/geocode/json?address=XXXX&bounds=XXXX&key=XXX
Address: address parts separated: XX+XX+XX+XX -> Larrys+Mansion+10+Downing+Street+London+SW1A+2AA
Bounds: latlong top left and latlong botton right: XX,XX|XX,XX -> 49.0,-14.0|61.0,2.0
PROMPT='%F{yellow}%n%F{white}@%F{green}%m:%F{blue} %B%~%b 🐈 %F{red}$%F{white} '
RPROMPT='${vcs_info_msg_0_}'
function pyramid(height) {
// row loop
for(let i = 0; i< height; i++) {
const whitespaces = height - (i + 1);
const stars = (2 * i) + 1;
const characters = ' '.repeat(whitespaces) + '*'.repeat(stars);
console.log(characters);
}