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
//inferance bottom up | |
// the compiler know function result type, baesed on it`s arguments | |
let userId = (a: string, b: number): string =>a+b; | |
//******************************* | |
//Union type (variable can be any of these types) | |
let thing: string | number | string[]; | |
// Alias | |
type thing = string | number | string[]; |
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 { getRandomWordSync, getRandomWord } = require("word-maker"); | |
const fs = require("fs"); | |
console.log("It works!"); | |
// YOUR CODE HERE | |
//Additional functions | |
//asynchronous in loop |
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
function delayedRandom(){ | |
const random = Math.random(); | |
return new Promise(resolve => setTimeout(()=>resolve(random), 100)); | |
} | |
async function* generateDelayedRandoms(){ | |
let num; | |
num = await delayedRandom() | |
yield 'One ' + num; |
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
// Object destructuring | |
//Object | |
const response = { | |
status: 200, | |
data: { | |
user: { | |
name: 'Rachel', | |
title: 'Editor in Chief' | |
}, |
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
import React from 'react'; | |
import { mount } from 'enzyme'; | |
import ParentComponent from './ParentComponent'; | |
import ChildComponent from './ChildComponent'; | |
describe('Parent component', () => { | |
it('adds and removes child component from the DOM', async () => { | |
const wrapper = mount(<ParentComponent />); | |
//Find button in Parent component |
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/support/commands.js | |
Cypress.Commands.add('mockOktaLoggedState', () => { | |
// Set cookies | |
cy.setCookie('okta-oauth-nonce', 'value of this cookie copied from the browser'); | |
cy.setCookie('okta-oauth-state', 'value of this cookie copied from the browser'); | |
// To avoid token expiration, we create a new timestamp every time | |
const oneDayFromNow = Date.now() + 1000 * 60 * 60 * 24; | |
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/support/commands.js | |
Cypress.Commands.add('loadRecipesPage', () => { | |
// One command can call another, just like plain functions | |
cy.mockOktaLoggedState(); | |
// When UI requests recipes, Cypress, not the actual server, will return response | |
cy.route('GET', '/api/recipes', 'fixture:recipes.json').as('recipes'); | |
// I can do manipulation on a fixture before serving it |
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/integration/recipes-page.test.js | |
describe('Recipes page', () => { | |
before(() => { | |
cy.loadRecipesPage(); | |
// Save selector as shortcuts, usefull if they will be used repetitively | |
cy.get('[data-cy=recipes-vegan-toggle] input').as('toggle'); | |
cy.get('[data-cy=recipes-vegan-toggle] label').as('toggleLabel'); | |
cy.get('[data-cy=recipe-card]').as('recipeCards'); |
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
{ | |
"sub": "00un7nfq2aTE0HOAl356", | |
"name": "Lula Leus", | |
"locale": "en-US", | |
"email": "[email protected]", | |
"preferred_username": "lulaleus", | |
"given_name": "Lula", | |
"family_name": "Leus", | |
"zoneinfo": "America/Los_Angeles", | |
"updated_at": 1559047283, |
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
function ListNode(val){ | |
this.val = val; | |
this.next = null; | |
} | |
function createList(arr){ | |
let result = arr.map((item, index, arr)=>{ | |
const node = new ListNode(item) | |
return node | |
}) |
OlderNewer