This file contains hidden or 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
type Review { | |
body: String | |
author: User @provides(fields: "username") | |
product: Product | |
} | |
extend type User @key(fields: "id") { | |
id: ID! @external | |
reviews: [Review] | |
} |
This file contains hidden or 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
// Node definition | |
function TreeNode(val) { | |
this.val = val; | |
this.left = this.right = null; | |
} | |
// Assemle a tree | |
const left = new TreeNode(2) | |
const right = new TreeNode(2) | |
const rightRight = new TreeNode(3) |
This file contains hidden or 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
/** | |
* @param {string} s | |
* @return {number} | |
*/ | |
var romanToInt = function(s) { | |
let result = 0 | |
const conversion = { | |
"I": 1, | |
"V": 5, | |
"X": 10, |
This file contains hidden or 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
// Can be used as foundation for algo questions which ask to split number into digits and manipulate it in some way afterward | |
function numberToSumOfDigits(num) { | |
let totalSum = 0; | |
while(num > 0){ | |
const digit = num %10 | |
num = Math.floor(num/10); | |
totalSum += digit | |
} | |
return totalSum |
This file contains hidden or 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 | |
}) |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 |