Skip to content

Commit

Permalink
tests: adapt for @octokit/endpoint v8
Browse files Browse the repository at this point in the history
  • Loading branch information
wolfy1339 committed Jun 13, 2023
1 parent a187776 commit eb8dcc2
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 16 deletions.
4 changes: 1 addition & 3 deletions test/defaults.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,7 @@ describe("endpoint.defaults()", () => {
[],
{
headers: {
accept:
"application/vnd.github.foo-preview.raw+json,application/vnd.github.bar-preview.raw+json",
accept: "application/vnd.github.v3.raw+json",
authorization: "token 0000000000000000000000000000000000000001",
"user-agent": "myApp/1.2.3",
},
Expand All @@ -63,7 +62,6 @@ describe("endpoint.defaults()", () => {
},
mediaType: {
format: "raw+json",
previews: ["foo", "bar"],
},
org: "my-project",
request: {
Expand Down
18 changes: 5 additions & 13 deletions test/request.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
{ id: 123 },
{
headers: {
accept: "application/vnd.github.machine-man-preview+json",
accept: "application/vnd.github.v3+json",
"user-agent": userAgent,
authorization: `bearer ${BEARER}`,
},
Expand All @@ -129,7 +129,7 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
{ id: 456 },
{
headers: {
accept: "application/vnd.github.machine-man-preview+json",
accept: "application/vnd.github.v3+json",
"user-agent": userAgent,
authorization: `token secret123`,
},
Expand All @@ -141,9 +141,6 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
installationId: 123,
});
const requestWithAuth = request.defaults({
mediaType: {
previews: ["machine-man"],
},
request: {
fetch: mock,
hook: auth.hook,
Expand Down Expand Up @@ -625,7 +622,6 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
},
mediaType: {
format: "",
previews: [],
},
method: "GET",
request: {
Expand Down Expand Up @@ -687,7 +683,7 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
it("options.mediaType.previews", function () {
const mock = fetchMock
.sandbox()
.mock("https://api.github.com/repos/octokit/request.js/issues/1", "ok", {
.mock("https://api.github.com/graphql", "ok", {
headers: {
accept:
"application/vnd.github.foo-preview+json,application/vnd.github.bar-preview+json",
Expand All @@ -696,16 +692,13 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
},
});

return request("GET /repos/{owner}/{repo}/issues/{number}", {
return request("GET /graphql", {
headers: {
authorization: "token 0000000000000000000000000000000000000001",
},
mediaType: {
previews: ["foo", "bar"],
},
owner: "octokit",
repo: "request.js",
number: 1,
request: {
fetch: mock,
},
Expand All @@ -732,15 +725,14 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w==
{
method: "PUT",
headers: {
accept: "application/vnd.github.luke-cage-preview+json",
accept: "application/vnd.github.v3+json",
authorization: "token secret123",
},
}
);

return request("PUT /repos/{owner}/{repo}/branches/{branch}/protection", {
baseUrl: "https://request-errors-test.com",
mediaType: { previews: ["luke-cage"] },
headers: {
authorization: "token secret123",
},
Expand Down

0 comments on commit eb8dcc2

Please sign in to comment.