Skip to content

Instantly share code, notes, and snippets.

@aloverso
aloverso / test-module.min.js
Created March 26, 2024 20:12
Test JS module load
function logGoogleEvent(action,label=void 0){"function"==typeof window.gtag&&window.gtag("event",action,{event_category:"Page feedback",event_label:label})}const LANG_TO_CONTENT={en:{ratingPrompt:"Did you find what you were looking for on this page?",ratingPositive:"Yes",ratingNegative:"No",commentPromptPositive:"Great! We're looking for ways to improve this page — what ideas come to mind?",commentPromptNegative:"Sorry to hear that. What were you looking for today?",commentPromptDisclaimer:"Your feedback helps improve this web page. For specific questions about your situation, ",commentPromptDisclaimerLink:"contact us",commentSubmit:"Send feedback",commentSubmitLoading:"Sending...",commentConfirmation:"Thanks for sharing your thoughts!",emailPrompt:"To hear about paid feedback opportunities in the future, join our user testing list.",emailLabel:"Email address",emailSubmit:"Join the list",emailSubmitLoading:"Joining...",errorMessage:"Try again, please. We didn't get your answer because of a technical issue.",e
{
"created_at": "Sun Nov 29 19:16:18 +0000 2019",
"id": 1333127345342797440,
"id_str": "1333127345342797440",
"truncated": false,
"entities": {
"symbols": [],
"user_entities": [
{
"name": "Firstname Lastname",
const getName = (response: ApiResponse): string => {
let fullName = "";
if (response.person.firstName && response.person.lastName) {
fullName = `${response.person.firstName} ${response.person.lastName}`
}
return fullName;
}
import externalApiFixtureData from "./onetTestDataTasks.json";
import {getUserDetailsForId} from "./apiClient.ts";
jest.mock("axios");
const mockedAxios = axios as jest.Mocked<typeof axios>;
describe("my cool external API integration", () => {
it("returns description when tasks and related occupations fail", async () => {
mockedAxios.get.mockResolvedValue({data: externalApiFixtureData})
@aloverso
aloverso / .zshrc
Last active December 10, 2020 14:09
zsh reminder to use ship-it
git() {
if [ "$1" = "push" ]
then
read "response?Are you sure you want to push without SHIP-IT????? [y/N] "
if [[ "$response" =~ ^([yY][eE][sS]|[yY])+$ ]]
then
command git "$@"
else
echo "NOT PUSHING, GREAT JOB BY YOU"
fi
@aloverso
aloverso / mock-example.test.tsx
Created July 17, 2020 18:28
mock a single function of a module in jest
function mockFunctions() {
const original = jest.requireActual('@reach/router');
return {
...original,
navigate: jest.fn(),
}
}
jest.mock('@reach/router', () => mockFunctions());
@aloverso
aloverso / outlook-custom.css
Last active May 26, 2020 19:31
Customizing outlook's web UI
/* i'm sorry but gmail's font is just better imo */
@font-face {
font-family: 'Segoe UI';
font-style: normal;
font-weight: 400;
src: local('Roboto'), local('Roboto-Regular'), url(https://fonts.gstatic.com/s/roboto/v20/KFOmCnqEu92Fr1Mu4mxKKTU1Kg.woff2) format('woff2');
unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+2000-206F, U+2074, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
it('transforms into a user entity', () => {
const user = buildDefaultUser({});
const expectedUserEntity = {
username: user.name,
password: user.password
};
expect(userTransformer.transform(user)).toEqual(expectedUserEntity);
});
export interface User {
name: String,
password: String
}
const random = (): number => {
return Math.floor(Math.random() * Math.floor(10000000));
};
export const buildDefaultUser = (partial: Partial<User>): User => {
@Test
void transformsIntoAUserEntity() {
// given a user
User user = easyRandom.nextObject(User.class);
// when we call transform on the user
UserEntity userEntity = userTransformer.transform(user);
// then we get a user entity with fields populated from the user fields