diff --git a/README.md b/README.md index b03db1031..c7f014fb8 100644 --- a/README.md +++ b/README.md @@ -145,41 +145,6 @@ const octokit = new Octokit({ }); ``` - - - - options.previews - - - Array of Strings - - - -Some REST API endpoints require preview headers to be set, or enable -additional features. Preview headers can be set on a per-request basis, e.g. - -```js -octokit.request("POST /repos/{owner}/{repo}/pulls", { - mediaType: { - previews: ["shadow-cat"], - }, - owner, - repo, - title: "My pull request", - base: "master", - head: "my-feature", - draft: true, -}); -``` - -You can also set previews globally, by setting the `options.previews` option on the constructor. Example: - -```js -const octokit = new Octokit({ - previews: ["shadow-cat"], -}); -``` - diff --git a/src/index.ts b/src/index.ts index 8ca8b1da1..86e4672d3 100644 --- a/src/index.ts +++ b/src/index.ts @@ -80,7 +80,6 @@ export class Octokit { hook: hook.bind(null, "request"), }), mediaType: { - previews: [], format: "", }, }; @@ -97,10 +96,6 @@ export class Octokit { requestDefaults.baseUrl = options.baseUrl; } - if (options.previews) { - requestDefaults.mediaType.previews = options.previews; - } - if (options.timeZone) { requestDefaults.headers["time-zone"] = options.timeZone; } diff --git a/src/types.ts b/src/types.ts index 0d0189f6a..72e2716c9 100644 --- a/src/types.ts +++ b/src/types.ts @@ -11,7 +11,6 @@ export interface OctokitOptions { authStrategy?: any; auth?: any; userAgent?: string; - previews?: string[]; baseUrl?: string; log?: { debug: (message: string) => unknown; diff --git a/test/auth.test.ts b/test/auth.test.ts index 18a4ad988..fe9e13f63 100644 --- a/test/auth.test.ts +++ b/test/auth.test.ts @@ -231,7 +231,6 @@ describe("Authentication", () => { { id: 123 }, { headers: { - accept: "application/vnd.github.machine-man-preview+json", "user-agent": userAgent, authorization: `bearer ${BEARER}`, }, @@ -253,11 +252,7 @@ describe("Authentication", () => { await octokit.request("GET /repos/octocat/hello-world"); await octokit.request("GET /repos/octocat/hello-world"); - await octokit.request("GET /app", { - mediaType: { - previews: ["machine-man"], - }, - }); + await octokit.request("GET /app"); expect(mock.done()).toBe(true); }); diff --git a/test/constructor.test.ts b/test/constructor.test.ts index b5bc8c0c0..b628099dc 100644 --- a/test/constructor.test.ts +++ b/test/constructor.test.ts @@ -2,32 +2,6 @@ import { Octokit } from "../src"; import fetchMock from "fetch-mock"; describe("Smoke test", () => { - it("previews option", () => { - const mock = fetchMock.sandbox().getOnce( - "https://api.github.com/", - { ok: true }, - { - headers: { - accept: - "application/vnd.github.jean-grey-preview+json,application/vnd.github.symmetra-preview+json", - }, - } - ); - - const octokit = new Octokit({ - previews: [ - // test with & without -preview suffix - "jean-grey-preview", - "symmetra", - ], - request: { - fetch: mock, - }, - }); - - return octokit.request("/"); - }); - it("timeZone option", () => { const mock = fetchMock.sandbox().getOnce( "https://api.github.com/", diff --git a/test/hook.test.ts b/test/hook.test.ts index 86e87cdc3..0bbce58ad 100644 --- a/test/hook.test.ts +++ b/test/hook.test.ts @@ -54,7 +54,6 @@ describe("octokit.hook", () => { "x-foo": "bar", }, mediaType: { - previews: ["octicon"], format: "rad", }, bar: "daz", @@ -77,7 +76,6 @@ describe("octokit.hook", () => { "x-foo": "bar", }, mediaType: { - previews: ["octicon"], format: "rad", }, }); @@ -104,7 +102,6 @@ describe("octokit.hook", () => { "user-agent": userAgent, }, mediaType: { - previews: [], format: "", }, request: { @@ -145,7 +142,6 @@ describe("octokit.hook", () => { "user-agent": userAgent, }, mediaType: { - previews: [], format: "", }, request: { @@ -178,7 +174,6 @@ describe("octokit.hook", () => { "user-agent": userAgent, }, mediaType: { - previews: [], format: "", }, request: { diff --git a/test/request.test.ts b/test/request.test.ts index d1a9f8141..bee4ffee8 100644 --- a/test/request.test.ts +++ b/test/request.test.ts @@ -94,49 +94,6 @@ describe("octokit.request()", () => { return octokit.request("GET /"); }); - it("previews", async () => { - const mock = fetchMock - .sandbox() - .getOnce( - "https://api.github.com/", - {}, - { - headers: { - accept: - "application/vnd.github.foo-preview+json,application/vnd.github.bar-preview+json", - "user-agent": userAgent, - }, - } - ) - .getOnce( - "https://api.github.com/", - {}, - { - headers: { - accept: - "application/vnd.github.foo-preview.raw,application/vnd.github.bar-preview.raw,application/vnd.github.baz-preview.raw", - "user-agent": userAgent, - }, - overwriteRoutes: false, - } - ); - - const octokit = new Octokit({ - previews: ["foo", "bar-preview"], - request: { - fetch: mock, - }, - }); - - await octokit.request("/"); - await octokit.request("/", { - mediaType: { - previews: ["bar", "baz-preview"], - format: "raw", - }, - }); - }); - it('octokit.request.endpoint("GET /")', () => { const octokit = new Octokit(); const requestOptions = octokit.request.endpoint("GET /");