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 { useEffect } from "react"; | |
| export const useSimpleChromeExtension = () => { | |
| useEffect(() => { | |
| if (!chrome.tabs) { | |
| // Will be undefined if open app not as Chrome extension | |
| return; | |
| } | |
| chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { |
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 { useEffect } from "react"; | |
| export const useSimpleChromeExtensionHook = () => { | |
| useEffect(() => { | |
| if (!chrome.tabs) { | |
| // Will be undefined if open app not as Chrome extension | |
| return; | |
| } | |
| chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { |
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 { useEffect } from "react"; | |
| export const useSimpleChromeExtensionHook = () => { | |
| useEffect(() => { | |
| // 1. Get the current active tab | |
| chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => { | |
| console.log(">>>>>>>> chrome.tabs.query <<<<<<<<<< ", tabs); | |
| const activeTabId = tabs[0].id as number; | |
| // 2. Execute a script in that active tab |
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
| const OLD = { | |
| image: { __typename__: 'Image' }, | |
| sprites: [ | |
| { x: 0, y: 0, width: 2, height: 2 }, | |
| { x: 0, y: 0, width: 2, height: 23 }, | |
| { x: 0, y: 0, width: 2, height: 36 }, | |
| { x: 0, y: 0, width: 2, height: 42 }, | |
| { x: 0, y: 0, width: 2, height: 48 }, | |
| { x: 0, y: 0, width: 2, height: 140 }, | |
| { x: 0, y: 0, width: 2, height: 129 }, |
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
| export const JSONContentMock: JSONContent = { | |
| doc: { | |
| type: 'doc', | |
| content: [ | |
| { | |
| type: 'heading', | |
| attrs: { level: 1 }, | |
| content: [{ type: 'text', text: 'Title' }], | |
| }, | |
| { |
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
| const students = [ | |
| { name: 'Alice', age: 20, grade: 4.5 }, | |
| { name: 'Bob', age: 21, grade: 3.9 }, | |
| { name: 'Charlie', age: 19, grade: 4.8 }, | |
| ]; | |
| const calculateAverageGrade = (studentArgument) => { | |
| let result = 0; | |
| // сумма всех баллов (версия 1) |
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 { ApolloClient, gql, useApolloClient } from '@apollo/client'; | |
| import Uppy from '@uppy/core'; | |
| // https://github.com/uuidjs/uuid#getrandomvalues-not-supported | |
| import 'react-native-get-random-values'; | |
| import { v4 as uuidv4 } from 'uuid'; | |
| import { translateScalar } from '@landr/mfe/src/utils/translateScalar'; | |
| import { useMemo } from 'react'; | |
| import { FileUploaderProps } from '@landr/mfe'; | |
| import { useFileUploader } from '@landr/mfe/src/customHooks/useFileUploader'; | |
| import * as DocumentPicker from 'expo-document-picker'; |
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
| expect(result.current.isTrue).toBe(false); | |
| - await waitForNextUpdate(); | |
| + await waitForNextUpdate({ | |
| + timeout: 2500, | |
| + }); | |
| expect(result.current.isTrue).toBe(true); | |
| }); |
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
| useEffect(() => { | |
| const id = setTimeout(() => { | |
| setIsTrue(true); | |
| - }, 1000); | |
| + }, 2000); | |
| return () => { | |
| clearTimeout(id); |
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 { renderHook, act } from '@testing-library/react-hooks'; | |
| import { useSimplestHook } from './1.simplest-hook'; | |
| it('should set to true', () => { | |
| const { result } = renderHook(() => useSimplestHook()); | |
| expect(result.current.isTrue).toBe(false); | |
| act(() => { | |
| result.current.toggle(); |
NewerOlder