Skip to content

Instantly share code, notes, and snippets.

Avatar
⚛️
Overreacting

Özcan Zafer AYAN ozcanzaferayan

⚛️
Overreacting
View GitHub Profile
@ozcanzaferayan
ozcanzaferayan / istekler.js
Created Apr 14, 2022
Linkedin tüm istekleri kabul etme / Linkedin accept all invitations
View istekler.js
var x = document.querySelectorAll('button.artdeco-button--secondary');
for (var i = 0; i < x.length; i++) {
x[i].click();
}
@ozcanzaferayan
ozcanzaferayan / App.test.tsx
Created Mar 6, 2022
Testing react component - auto mocking - App.test.tsx
View App.test.tsx
import { fireEvent, render, screen } from "@testing-library/react";
import App from "./App";
import fetchMock from "jest-fetch-mock";
import fetch from "jest-fetch-mock";
fetchMock.enableMocks();
beforeEach(() => {
fetch.resetMocks();
});
@ozcanzaferayan
ozcanzaferayan / Repos.test.tsx
Created Mar 4, 2022
Testing react components - Repos.test.tsx
View Repos.test.tsx
import { fireEvent, render, screen } from "@testing-library/react";
import Repos from "./Repos";
test("renders user's repos", async () => {
render(<Repos />);
const button = screen.getByText(/Get repos/i);
fireEvent.click(button);
const txtRepo = await screen.findByText(/boysenberry/i);
expect(txtRepo).toBeInTheDocument();
@ozcanzaferayan
ozcanzaferayan / setupTests.ts
Created Mar 4, 2022
Testing react components - setupTests.ts
View setupTests.ts
// jest-dom adds custom jest matchers for asserting on DOM nodes.
// allows you to do things like:
// expect(element).toHaveTextContent(/react/i)
// learn more: https://github.com/testing-library/jest-dom
import "@testing-library/jest-dom";
const unmockedFetch = global.fetch;
beforeAll(() => {
const getDataByUrl = (url: string) => {
switch (url) {
@ozcanzaferayan
ozcanzaferayan / Repos.tsx
Created Mar 4, 2022
Testing react components - Repos.tsx
View Repos.tsx
import { useState } from "react";
type Repo = {
full_name: string;
};
function Repos() {
const [repos, setRepos] = useState<Repo[] | null>(null);
const [userName, setUserName] = useState<string>("octocat");
const getRepos = () => {
@ozcanzaferayan
ozcanzaferayan / App.test.tsx
Last active Mar 4, 2022
Testing react components - App.test.tsx
View App.test.tsx
import { fireEvent, render, screen } from "@testing-library/react";
import App from "./App";
const unmockedFetch = global.fetch;
beforeAll(() => {
global.fetch = () =>
Promise.resolve({
json: () =>
Promise.resolve({
@ozcanzaferayan
ozcanzaferayan / App.tsx
Last active Mar 4, 2022
Testing React component - App.tsx
View App.tsx
import { useState } from "react";
type User = {
name: string;
followers: string;
following: string;
};
function App() {
const [user, setUser] = useState<User | null>(null);
View FrameHostObject.cpp
#import "FrameHostObject.h"
#import <Foundation/Foundation.h>
#import <jsi/jsi.h>
// This method returns all of keys
std::vector<jsi::PropNameID> FrameHostObject::getPropertyNames(jsi::Runtime& rt) {
std::vector<jsi::PropNameID> result;
result.push_back(jsi::PropNameID::forUtf8(rt, std::string("toString")));
result.push_back(jsi::PropNameID::forUtf8(rt, std::string("isValid")));
result.push_back(jsi::PropNameID::forUtf8(rt, std::string("width")));
View FrameHostObject.h
#pragma once
#import <jsi/jsi.h>
#import <CoreMedia/CMSampleBuffer.h>
#import "Frame.h"
using namespace facebook;
class JSI_EXPORT FrameHostObject: public jsi::HostObject {
public:
@ozcanzaferayan
ozcanzaferayan / index.js
Last active Jan 15, 2022
Wordle en mantıklı başlangıç kelimeleri
View index.js
const list = [
"abacı",
"abadi",
"abalı",
"abana",
"abani",
"abaşo",
"abaza",
"abbas",
"abdal",