forked from anuraghazra/github-readme-stats
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add pin card performance test (anuraghazra#3374)
- Loading branch information
Showing
1 changed file
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains 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
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); | ||
}, | ||
}); |