This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type Camelize<GenericObject> = { | |
[ObjectProperty in keyof GenericObject as CamelizeString<ObjectProperty & string>]: | |
GenericObject[ObjectProperty] extends Array<infer ArrayItem> | |
? ArrayItem extends Record<string, unknown> | |
? Array<Camelize<ArrayItem>> | |
: GenericObject[ObjectProperty] | |
: GenericObject[ObjectProperty] extends Record<string, unknown> | |
? Camelize<GenericObject[ObjectProperty]> | |
: GenericObject[ObjectProperty]; | |
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type CamelizeString<ObjectProperty extends string> = | |
ObjectProperty extends `${infer F}_${infer R}` | |
? `${F}${Capitalize<CamelizeString<R>>}` | |
: ObjectProperty; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export type CamelizeString<ObjectProperty extends string> = | |
ObjectProperty extends `${infer F}_${infer R}` | |
? `${F}${Capitalize<CamelizeString<R>>}` | |
: ObjectProperty; | |
export type Camelize<GenericObject> = { | |
[ObjectProperty in keyof GenericObject as CamelizeString<ObjectProperty & string>]: | |
GenericObject[ObjectProperty] extends Array<infer ArrayItem> | |
? ArrayItem extends Record<string, unknown> | |
? Array<Camelize<ArrayItem>> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.image-gallery { | |
display: grid; | |
grid-gap: 5px; | |
} | |
.image-gallery img { | |
height: 250px; | |
width: 250px; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
describe('fb social login', () => { | |
it('should be able to login with fb', () => { | |
cy.visit('http://localhost:3000'); | |
return cy.loginByFacebook().then(() => { | |
cy.get('[data-testid="fb-login-button"]') | |
.should('be.enabled') | |
.click(); | |
cy.location('pathname').should('eq', '/home'); | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cypress.Commands.add('loginByFacebook', ( | |
status: 'connected' | 'not_authorized' | 'unknown' = 'connected' | |
) => { | |
return cy.window().then((win) => { | |
const callbackResult = { | |
...status === 'connected' && { | |
status: 'connected', | |
authResponse: { | |
accessToken: 'test_fbAccessToken', | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const person01 = { | |
name: 'JM' | |
}; | |
/** | |
* Clone/copy all the values in `person01` | |
*/ | |
const person02 = { ...person01 }; | |
/** |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let person01 = 'JM'; | |
let person02 = person01; | |
person02 = 'JM Santos'; | |
console.log('person01', person01); // JM | |
console.log('person02', person02); // JM Santos |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const person01 = { | |
name: 'JM' | |
}; | |
const person02 = person01; | |
/** | |
* Mutating `person02` will cause effect also on `person01` because | |
* `person01` was assigned by reference not by value | |
*/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let y = 3; | |
/** | |
* The `sum` function is accessing the global variable `y` to compute for the sum | |
*/ | |
const sum = (x) => x + y; | |
/** | |
* Here we are mutating the state of the variable `y` to `6` | |
* which means that the computation of `sum` will now be different |
NewerOlder