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 "./styles.css"; | |
| import React, { useCallback, useState } from "react"; | |
| import pokemonData from "./mockData.json"; | |
| import { useDebounce } from "./useDebounce"; | |
| import { useThrottle } from "./useThrottle"; | |
| export default function App() { | |
| const [autocompleteInput, setAutocompleteInput] = useState(""); | |
| const [pokemonArr, setPokemonArr] = useState([]); | 
  
    
      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 { useState } from "react"; | |
| export const useThrottle = (fn, timer = 1000) => { | |
| const [timeoutId, setTimeoutId] = useState(null); | |
| return (...args) => { | |
| if (timeoutId) { | |
| return; | |
| } | |
| setTimeoutId( | |
| setTimeout(() => { | 
  
    
      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 { useState } from "react"; | |
| export const useDebounce = (fn, timer = 1000) => { | |
| const [timeoutId, setTimeoutId] = useState(null); | |
| return (...args) => { | |
| if (timeoutId) { | |
| clearTimeout(timeoutId); | |
| setTimeoutId(null); | |
| } | |
| setTimeoutId( | 
  
    
      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 "./styles.css"; | |
| import React, { useCallback, useState } from "react"; | |
| import pokemonData from "./mockData.json"; | |
| const customDebounce = (fn, timer = 1000) => { | |
| let timeOutValue = null; | |
| return (...args) => { | |
| if (timeOutValue) { | |
| clearTimeout(timeOutValue); | |
| } | 
  
    
      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
    
  
  
    
  | .App { | |
| font-family: sans-serif; | |
| display: flex; | |
| flex-direction: column; | |
| justify-content: center; | |
| align-items: center; | |
| margin-top: 10px; | |
| } | |
| .autocompleteInput { | 
  
    
      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
    
  
  
    
  | [ | |
| "bulbasaur", | |
| "ivysaur", | |
| "venusaur", | |
| "charmander", | |
| "charmeleon", | |
| "charizard", | |
| "squirtle", | |
| "wartortle", | |
| "blastoise", | 
  
    
      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 "./styles.css"; | |
| import React, { useCallback, useState } from "react"; | |
| import pokemonData from "./mockData.json"; | |
| export default function App() { | |
| const [autocompleteInput, setAutocompleteInput] = useState(""); | |
| const [pokemonArr, setPokemonArr] = useState([]); | |
| const filterPokemons = (keyword) => { | |
| console.log("filter pokemon"); | 
  
    
      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
    
  
  
    
  | it('returns 200 on successfull signout', async(done)=>{ | |
| request(app) | |
| .post('/api/users/auth/signout') | |
| .send({}) | |
| .expect(200) | |
| .end((err, res) => { | |
| if (err) { | |
| return done(err); | |
| } | |
| expect(res.body.message).toBe('success'); | 
  
    
      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
    
  
  
    
  | it('disallows duplicate emails', async(done)=>{ | |
| await request(app) | |
| .post('/api/users/auth/signup') | |
| .send({ | |
| email : 'test@test.com', | |
| password: 'password' | |
| }) | |
| .expect(201); | |
| request(app) | |
| .post('/api/users/auth/signup') | 
  
    
      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
    
  
  
    
  | it('check if cookies are set in successful signup response', async()=>{ | |
| const resp = await request(app) | |
| .post('/api/users/auth/signup') | |
| .send({ | |
| email : 'test@test.com', | |
| password: 'password' | |
| }); | |
| expect( resp.get('Set-Cookie') ).toBeDefined(); | |
| }); | 
NewerOlder