Skip to content

Commit

Permalink
tests: add pin card performance test (anuraghazra#3374)
Browse files Browse the repository at this point in the history
  • Loading branch information
qwerty541 authored Nov 28, 2023
1 parent 0616df3 commit 1656ec6
Showing 1 changed file with 50 additions and 0 deletions.
50 changes: 50 additions & 0 deletions tests/bench/pin.bench.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import { benchmarkSuite } from "jest-bench";
import pin from "../../api/pin.js";
import axios from "axios";
import MockAdapter from "axios-mock-adapter";
import { jest } from "@jest/globals";

const data_repo = {
repository: {
username: "anuraghazra",
name: "convoychat",
stargazers: {
totalCount: 38000,
},
description: "Help us take over the world! React + TS + GraphQL Chat App",
primaryLanguage: {
color: "#2b7489",
id: "MDg6TGFuZ3VhZ2UyODc=",
name: "TypeScript",
},
forkCount: 100,
isTemplate: false,
},
};

const data_user = {
data: {
user: { repository: data_repo.repository },
organization: null,
},
};

const mock = new MockAdapter(axios);
mock.onPost("https://api.github.com/graphql").reply(200, data_user);

benchmarkSuite("test /api/pin", {
["simple request"]: async () => {
const req = {
query: {
username: "anuraghazra",
repo: "convoychat",
},
};
const res = {
setHeader: jest.fn(),
send: jest.fn(),
};

await pin(req, res);
},
});

0 comments on commit 1656ec6

Please sign in to comment.