Skip to content

Commit fa850ab

Browse files
wolfy1339oscard0m
authored andcommitted
feat: remove previews
1 parent 43dab02 commit fa850ab

File tree

7 files changed

+1
-121
lines changed

7 files changed

+1
-121
lines changed

README.md

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -145,41 +145,6 @@ const octokit = new Octokit({
145145
});
146146
```
147147

148-
</td></tr>
149-
<tr>
150-
<th>
151-
<code>options.previews</code>
152-
</th>
153-
<td>
154-
<code>Array of Strings</code>
155-
</td>
156-
<td>
157-
158-
Some REST API endpoints require preview headers to be set, or enable
159-
additional features. Preview headers can be set on a per-request basis, e.g.
160-
161-
```js
162-
octokit.request("POST /repos/{owner}/{repo}/pulls", {
163-
mediaType: {
164-
previews: ["shadow-cat"],
165-
},
166-
owner,
167-
repo,
168-
title: "My pull request",
169-
base: "master",
170-
head: "my-feature",
171-
draft: true,
172-
});
173-
```
174-
175-
You can also set previews globally, by setting the `options.previews` option on the constructor. Example:
176-
177-
```js
178-
const octokit = new Octokit({
179-
previews: ["shadow-cat"],
180-
});
181-
```
182-
183148
</td></tr>
184149
<tr>
185150
<th>

src/index.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,6 @@ export class Octokit {
8080
hook: hook.bind(null, "request"),
8181
}),
8282
mediaType: {
83-
previews: [],
8483
format: "",
8584
},
8685
};
@@ -97,10 +96,6 @@ export class Octokit {
9796
requestDefaults.baseUrl = options.baseUrl;
9897
}
9998

100-
if (options.previews) {
101-
requestDefaults.mediaType.previews = options.previews;
102-
}
103-
10499
if (options.timeZone) {
105100
requestDefaults.headers["time-zone"] = options.timeZone;
106101
}

src/types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export interface OctokitOptions {
1111
authStrategy?: any;
1212
auth?: any;
1313
userAgent?: string;
14-
previews?: string[];
1514
baseUrl?: string;
1615
log?: {
1716
debug: (message: string) => unknown;

test/auth.test.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -231,7 +231,6 @@ describe("Authentication", () => {
231231
{ id: 123 },
232232
{
233233
headers: {
234-
accept: "application/vnd.github.machine-man-preview+json",
235234
"user-agent": userAgent,
236235
authorization: `bearer ${BEARER}`,
237236
},
@@ -253,11 +252,7 @@ describe("Authentication", () => {
253252
await octokit.request("GET /repos/octocat/hello-world");
254253
await octokit.request("GET /repos/octocat/hello-world");
255254

256-
await octokit.request("GET /app", {
257-
mediaType: {
258-
previews: ["machine-man"],
259-
},
260-
});
255+
await octokit.request("GET /app");
261256

262257
expect(mock.done()).toBe(true);
263258
});

test/constructor.test.ts

Lines changed: 0 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -2,32 +2,6 @@ import { Octokit } from "../src";
22
import fetchMock from "fetch-mock";
33

44
describe("Smoke test", () => {
5-
it("previews option", () => {
6-
const mock = fetchMock.sandbox().getOnce(
7-
"https://api.github.com/",
8-
{ ok: true },
9-
{
10-
headers: {
11-
accept:
12-
"application/vnd.github.jean-grey-preview+json,application/vnd.github.symmetra-preview+json",
13-
},
14-
}
15-
);
16-
17-
const octokit = new Octokit({
18-
previews: [
19-
// test with & without -preview suffix
20-
"jean-grey-preview",
21-
"symmetra",
22-
],
23-
request: {
24-
fetch: mock,
25-
},
26-
});
27-
28-
return octokit.request("/");
29-
});
30-
315
it("timeZone option", () => {
326
const mock = fetchMock.sandbox().getOnce(
337
"https://api.github.com/",

test/hook.test.ts

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ describe("octokit.hook", () => {
5454
"x-foo": "bar",
5555
},
5656
mediaType: {
57-
previews: ["octicon"],
5857
format: "rad",
5958
},
6059
bar: "daz",
@@ -77,7 +76,6 @@ describe("octokit.hook", () => {
7776
"x-foo": "bar",
7877
},
7978
mediaType: {
80-
previews: ["octicon"],
8179
format: "rad",
8280
},
8381
});
@@ -104,7 +102,6 @@ describe("octokit.hook", () => {
104102
"user-agent": userAgent,
105103
},
106104
mediaType: {
107-
previews: [],
108105
format: "",
109106
},
110107
request: {
@@ -145,7 +142,6 @@ describe("octokit.hook", () => {
145142
"user-agent": userAgent,
146143
},
147144
mediaType: {
148-
previews: [],
149145
format: "",
150146
},
151147
request: {
@@ -178,7 +174,6 @@ describe("octokit.hook", () => {
178174
"user-agent": userAgent,
179175
},
180176
mediaType: {
181-
previews: [],
182177
format: "",
183178
},
184179
request: {

test/request.test.ts

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -94,49 +94,6 @@ describe("octokit.request()", () => {
9494
return octokit.request("GET /");
9595
});
9696

97-
it("previews", async () => {
98-
const mock = fetchMock
99-
.sandbox()
100-
.getOnce(
101-
"https://api.github.com/",
102-
{},
103-
{
104-
headers: {
105-
accept:
106-
"application/vnd.github.foo-preview+json,application/vnd.github.bar-preview+json",
107-
"user-agent": userAgent,
108-
},
109-
}
110-
)
111-
.getOnce(
112-
"https://api.github.com/",
113-
{},
114-
{
115-
headers: {
116-
accept:
117-
"application/vnd.github.foo-preview.raw,application/vnd.github.bar-preview.raw,application/vnd.github.baz-preview.raw",
118-
"user-agent": userAgent,
119-
},
120-
overwriteRoutes: false,
121-
}
122-
);
123-
124-
const octokit = new Octokit({
125-
previews: ["foo", "bar-preview"],
126-
request: {
127-
fetch: mock,
128-
},
129-
});
130-
131-
await octokit.request("/");
132-
await octokit.request("/", {
133-
mediaType: {
134-
previews: ["bar", "baz-preview"],
135-
format: "raw",
136-
},
137-
});
138-
});
139-
14097
it('octokit.request.endpoint("GET /")', () => {
14198
const octokit = new Octokit();
14299
const requestOptions = octokit.request.endpoint("GET /");

0 commit comments

Comments
 (0)