diff --git a/test/integration/agent-ca/agent-ca-test.js b/test/integration/agent-ca/agent-ca-test.js deleted file mode 100644 index 35c4d38c..00000000 --- a/test/integration/agent-ca/agent-ca-test.js +++ /dev/null @@ -1,83 +0,0 @@ -const { readFileSync } = require("node:fs"); -const { resolve } = require("node:path"); -const { fetch: undiciFetch, Agent } = require("undici"); - -const { Octokit } = require("../../.."); -const ca = readFileSync(resolve(__dirname, "./ca.crt")); - -describe("custom client certificate", () => { - let server; - before((done) => { - server = https.createServer( - { - key: readFileSync(resolve(__dirname, "./localhost.key")), - cert: readFileSync(resolve(__dirname, "./localhost.crt")), - }, - function (request, response) { - expect(request.method).to.equal("GET"); - expect(request.url).to.equal("/repos/octokit/rest.js"); - - response.writeHead(200); - response.write("ok"); - response.end(); - }, - ); - - server.listen(0, done); - }); - - it("undici.Agent({ca})", () => { - const agent = new Agent({ - keepAliveTimeout: 10, - keepAliveMaxTimeout: 10, - connect: { ca: ca }, - }); - const myFetch = (url, opts) => { - return undiciFetch(url, { - ...opts, - dispatcher: agent, - }); - }; - const octokit = new Octokit({ - baseUrl: "https://localhost:" + server.address().port, - request: { - fetch: myFetch, - }, - }); - - return octokit.rest.repos.get({ - owner: "octokit", - repo: "rest.js", - }); - }); - - it("undici.Agent({ca, rejectUnauthorized})", () => { - const agent = new Agent({ - keepAliveTimeout: 10, - keepAliveMaxTimeout: 10, - connect: { - ca: "invalid", - rejectUnauthorized: true, - }, - }); - const myFetch = (url, opts) => { - return undiciFetch(url, { - ...opts, - dispatcher: agent, - }); - }; - const octokit = new Octokit({ - baseUrl: "https://localhost:" + server.address().port, - request: { - fetch: myFetch, - }, - }); - - return octokit.rest.repos.get({ - owner: "octokit", - repo: "rest.js", - }); - }); - - after((done) => server.close(done)); -}); diff --git a/test/integration/agent-ca/agent-ca.test.ts b/test/integration/agent-ca/agent-ca.test.ts new file mode 100644 index 00000000..9e6d3c64 --- /dev/null +++ b/test/integration/agent-ca/agent-ca.test.ts @@ -0,0 +1,88 @@ +import { describe, it, expect, beforeAll, afterAll } from "vitest"; +import { readFileSync } from "node:fs"; +import { fetch as undiciFetch, Agent } from "undici"; +import https from "node:https"; + +import { Octokit } from "../../../src/index.ts"; +import type { AddressInfo } from "node:net"; +const ca = readFileSync(new URL("./ca.crt", import.meta.url)); + +describe("custom client certificate", () => { + let server: https.Server; + beforeAll( + () => + new Promise((done) => { + server = https.createServer( + { + key: readFileSync(new URL("./localhost.key", import.meta.url)), + cert: readFileSync(new URL("./localhost.crt", import.meta.url)), + }, + function (request, response) { + expect(request.method).toStrictEqual("GET"); + expect(request.url).toStrictEqual("/repos/octokit/rest.js"); + + response.writeHead(200); + response.write("ok"); + response.end(); + }, + ); + + server.listen(0, done); + }), + ); + + it("undici.Agent({ca})", () => { + const agent = new Agent({ + keepAliveTimeout: 10, + keepAliveMaxTimeout: 10, + connect: { ca: ca }, + }); + const myFetch = (url, opts) => { + return undiciFetch(url, { + ...opts, + dispatcher: agent, + }); + }; + const octokit = new Octokit({ + baseUrl: "https://localhost:" + (server.address() as AddressInfo).port, + request: { + fetch: myFetch, + }, + }); + + return octokit.rest.repos.get({ + owner: "octokit", + repo: "rest.js", + }); + }); + + it("undici.Agent({ca, rejectUnauthorized})", () => { + const agent = new Agent({ + keepAliveTimeout: 10, + keepAliveMaxTimeout: 10, + connect: { + ca: "invalid", + rejectUnauthorized: true, + }, + }); + const myFetch = (url, opts) => { + return undiciFetch(url, { + ...opts, + dispatcher: agent, + }); + }; + const octokit = new Octokit({ + baseUrl: "https://localhost:" + (server.address() as AddressInfo).port, + request: { + fetch: myFetch, + }, + }); + + return octokit.rest.repos.get({ + owner: "octokit", + repo: "rest.js", + }); + }); + + afterAll(() => new Promise(() => server.close())); +}); diff --git a/test/integration/apps-test.js b/test/integration/apps-test.js deleted file mode 100644 index 634cd8f3..00000000 --- a/test/integration/apps-test.js +++ /dev/null @@ -1,48 +0,0 @@ -const nock = require("nock"); - -const { Octokit } = require("../../"); -const BEARER_TOKEN = - "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NTM4MTkzMTIsImV4cCI6MTU1MzgxOTM3MiwiaXNzIjoxfQ.etiSZ4LFQZ8tiMGJVqKDoGn8hxMCgwL4iLvU5xBUqbAPr4pbk_jJZmMQjuxTlOnRxq4e7NouTizGCdfohRMb3R1mpLzGPzOH9_jqSA_BWYxolsRP_WDSjuNcw6nSxrPRueMVRBKFHrqcTOZJej0djRB5pI61hDZJ_-DGtiOIFexlK3iuVKaqBkvJS5-TbTekGuipJ652g06gXuz-l8i0nHiFJldcuIruwn28hTUrjgtPbjHdSBVn_QQLKc2Fhij8OrhcGqp_D_fvb_KovVmf1X6yWiwXV5VXqWARS-JGD9JTAr2495ZlLV_E4WPxdDpz1jl6XS9HUhMuwBpaCOuipw"; - -describe("apps", () => { - let octokit; - - beforeEach(() => { - octokit = new Octokit({ - baseUrl: "https://apps-test-host.com", - auth: `Bearer ${BEARER_TOKEN}`, - log: console.log, - }); - }); - - it('adds "machine-man" preview header', () => { - nock("https://apps-test-host.com", { - reqheaders: { - authorization: `bearer ${BEARER_TOKEN}`, - accept: "application/vnd.github.machine-man-preview+json", - }, - }) - .get("/app") - .reply(200, {}); - - return octokit.rest.apps.getAuthenticated(); - }); - - it('adds "machine-man" preview header to custom media type', () => { - nock("https://apps-test-host.com", { - reqheaders: { - authorization: `bearer ${BEARER_TOKEN}`, - accept: - "application/vnd.github.machine-man-preview+json,application/vnd.github.foo-bar-preview+json", - }, - }) - .get("/app") - .reply(200, {}); - - return octokit.rest.apps.getAuthenticated({ - mediaType: { - previews: ["foo-bar"], - }, - }); - }); -}); diff --git a/test/integration/apps.test.js b/test/integration/apps.test.js new file mode 100644 index 00000000..5d431cd8 --- /dev/null +++ b/test/integration/apps.test.js @@ -0,0 +1,19 @@ +import nock from "nock"; + +import { Octokit } from "../../pkg/dist-src/index.js"; +const BEARER_TOKEN = + "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NTM4MTkzMTIsImV4cCI6MTU1MzgxOTM3MiwiaXNzIjoxfQ.etiSZ4LFQZ8tiMGJVqKDoGn8hxMCgwL4iLvU5xBUqbAPr4pbk_jJZmMQjuxTlOnRxq4e7NouTizGCdfohRMb3R1mpLzGPzOH9_jqSA_BWYxolsRP_WDSjuNcw6nSxrPRueMVRBKFHrqcTOZJej0djRB5pI61hDZJ_-DGtiOIFexlK3iuVKaqBkvJS5-TbTekGuipJ652g06gXuz-l8i0nHiFJldcuIruwn28hTUrjgtPbjHdSBVn_QQLKc2Fhij8OrhcGqp_D_fvb_KovVmf1X6yWiwXV5VXqWARS-JGD9JTAr2495ZlLV_E4WPxdDpz1jl6XS9HUhMuwBpaCOuipw"; + +describe.skip("apps", () => { + let octokit; + + beforeEach(() => { + octokit = new Octokit({ + baseUrl: "https://apps-test-host.com", + auth: `Bearer ${BEARER_TOKEN}`, + log: console, + }); + }); + + it("No test currently implemented", () => {}); +}); diff --git a/test/integration/authentication-test.js b/test/integration/authentication.test.js similarity index 95% rename from test/integration/authentication-test.js rename to test/integration/authentication.test.js index a0cd15c4..efe33f35 100644 --- a/test/integration/authentication-test.js +++ b/test/integration/authentication.test.js @@ -1,9 +1,9 @@ -const lolex = require("lolex"); -const nock = require("nock"); -const { createAppAuth } = require("@octokit/auth-app"); -const { createActionAuth } = require("@octokit/auth-action"); +import { install } from "@sinonjs/fake-timers"; +import nock from "nock"; +import { createAppAuth } from "@octokit/auth-app"; +import { createActionAuth } from "@octokit/auth-action"; -const { Octokit } = require("../.."); +import { Octokit } from "../../pkg/dist-src/index.js"; describe("authentication", () => { it("unauthenticated", () => { @@ -14,7 +14,7 @@ describe("authentication", () => { }); return octokit.auth().then((authentication) => { - expect(authentication).to.deep.equal({ + expect(authentication).toStrictEqual({ type: "unauthenticated", }); }); @@ -120,7 +120,7 @@ describe("authentication", () => { it("invalid auth errors", () => { expect(() => { Octokit({ auth: {}, log: { warn() {} } }); - }).to.throw(Error); + }).toThrow(Error); }); it("action auth strategy", async () => { @@ -203,7 +203,7 @@ x//0u+zd/R/QRUzLOw4N72/Hu+UG6MNt5iDZFCtapRaKt6OvSBwy8w== .get("/") .reply(200, {}); - const clock = lolex.install({ + const clock = install({ now: 0, toFake: ["Date"], }); diff --git a/test/integration/conditional-request-test.js b/test/integration/conditional-request.test.js similarity index 83% rename from test/integration/conditional-request-test.js rename to test/integration/conditional-request.test.js index 7bc4369f..a29b37e6 100644 --- a/test/integration/conditional-request-test.js +++ b/test/integration/conditional-request.test.js @@ -1,6 +1,6 @@ -const nock = require("nock"); +import nock from "nock"; -const { Octokit } = require("../../"); +import { Octokit } from "../../pkg/dist-src/index.js"; describe("request 304s", () => { let octokit; @@ -20,7 +20,7 @@ describe("request 304s", () => { expect.fail("should throw error"); }) .catch((error) => { - expect(error.status).to.equal(304); + expect(error.status).toStrictEqual(304); }); }); @@ -38,7 +38,7 @@ describe("request 304s", () => { expect.fail("should throw error"); }) .catch((error) => { - expect(error.status).to.equal(304); + expect(error.status).toStrictEqual(304); }); }); }); diff --git a/test/integration/deprecations-test.js b/test/integration/deprecations.test.js similarity index 70% rename from test/integration/deprecations-test.js rename to test/integration/deprecations.test.js index bff6f054..cb8cc4a9 100644 --- a/test/integration/deprecations-test.js +++ b/test/integration/deprecations.test.js @@ -1,146 +1,20 @@ -const btoa = require("btoa-lite"); -const nock = require("nock"); +import nock from "nock"; -const DeprecatedOctokit = require("../../"); -const { Octokit } = DeprecatedOctokit; +import { Octokit } from "../../pkg/dist-src/index.js"; const Mocktokit = Octokit.plugin((octokit) => { octokit.hook.wrap("request", () => null); }); -describe("deprecations", () => { - it('const Octokit = require("@octokit/rest")', () => { - let warnCalledCount = 0; - new DeprecatedOctokit({ - log: { - warn: () => { - warnCalledCount++; - }, - }, - }); - - expect(warnCalledCount).to.equal(1); - expect(() => new DeprecatedOctokit()).to.not.throw(); - expect(typeof DeprecatedOctokit.plugin).to.equal("function"); - }); - it("octokit.rest.search.issues() has been renamed to octokit.rest.search.issuesAndPullRequests() (2018-12-27)", () => { - let warnCalledCount = 0; - const octokit = new Mocktokit({ - log: { - warn: (deprecation) => { - warnCalledCount++; - }, - }, - }); - - return Promise.all([ - octokit.rest.search.issues({ q: "foo" }), - octokit.rest.search.issues({ q: "foo" }), - ]).then(() => { - expect(warnCalledCount).to.equal(1); - }); - }); - - it('"number" parameter has been renamed to "issue_number" (2019-04-10)', () => { - nock("https://deprecation-host.com") - .get("/repos/octocat/hello-world/issues/123") - .twice() - .reply(200, {}); - - let warnCalledCount = 0; - const octokit = new Octokit({ - baseUrl: "https://deprecation-host.com", - log: { - warn: (deprecation) => { - warnCalledCount++; - }, - }, - }); - - return Promise.all([ - octokit.rest.issues.get({ - owner: "octocat", - repo: "hello-world", - number: 123, - }), - octokit.rest.issues.get({ - owner: "octocat", - repo: "hello-world", - number: 123, - }), - ]).then(() => { - // Ideally it would only log once, but it’s unclear on how to implement that - // without adding significant complexity - expect(warnCalledCount).to.equal(2); - }); - }); - - it("deprecated parameter: passing both new and deprecated parameter", () => { - nock("https://deprecation-host.com") - .get("/repos/octocat/hello-world/issues/456") - .twice() - .reply(200, {}); - - let warnCalledCount = 0; - const octokit = new Octokit({ - baseUrl: "https://deprecation-host.com", - log: { - warn: (deprecation) => { - warnCalledCount++; - }, - }, - }); - - return octokit.rest.issues - .get({ - owner: "octocat", - repo: "hello-world", - number: 123, - issue_number: 456, - }) - .then(() => { - expect(warnCalledCount).to.equal(1); - }); - }); - +describe.skip("deprecations", () => { it("deprecated parameter: passing no options", () => { const octokit = new Octokit(); return octokit.rest.issues.get().catch((error) => { - expect(error.status).to.equal(400); + expect(error.status).toStrictEqual(400); }); }); - it("octokit.rest.issues.get.endpoint({owner, repo, number}) returns correct URL and logs deprecation", () => { - let warnCalledCount = 0; - const octokit = new Octokit({ - log: { - warn() { - warnCalledCount++; - }, - }, - }); - - const { url } = octokit.rest.issues.get.endpoint({ - owner: "octocat", - repo: "hello-world", - number: 123, - }); - const options = octokit.rest.issues.get.endpoint.merge({ - owner: "octocat", - repo: "hello-world", - number: 123, - }); - - expect(url).to.equal( - "https://api.github.com/repos/octocat/hello-world/issues/123", - ); - expect(options.url).to.equal("/repos/{owner}/{repo}/issues/{issue_number}"); - expect("number" in options).to.equal(false); - expect(options.issue_number).to.equal(123); - expect(warnCalledCount).to.equal(2); - }); - it("octokit.paginate(octokit.rest.pulls.listReviews.merge({owner, repo, number}))", () => { nock("https://deprecation-host.com") .get("/repos/octocat/hello-world/pulls/123/reviews") @@ -198,130 +72,8 @@ describe("deprecations", () => { }); return octokit.paginate(options).then((response) => { - expect(warnCalledCount).to.equal(1); - }); - }); - - it("octokit.authenticate(): basic", () => { - nock("https://authentication-test-host.com", { - reqheaders: { - authorization: "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", - }, - }) - .get("/orgs/myorg") - .reply(200, {}); - - let warnCalledCount = 0; - const octokit = new Octokit({ - baseUrl: "https://authentication-test-host.com", - log: { - warn: () => { - warnCalledCount++; - }, - }, - }); - - octokit.authenticate({ - type: "basic", - username: "username", - password: "password", - }); - - octokit.authenticate({ - type: "basic", - username: "username", - password: "password", - }); - - expect(warnCalledCount).to.equal(1); - - return octokit.rest.orgs.get({ org: "myorg" }); - }); - - it("octokit.authenticate(): basic with 2fa", () => { - nock("https://authentication-test-host.com", { - reqheaders: { - authorization: "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", - }, - }) - .get("/orgs/myorg") - .reply( - 401, - {}, - { - "x-github-otp": "required; app", - }, - ); - - nock("https://authentication-test-host.com", { - reqheaders: { - authorization: "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", - "x-github-otp": "123456", - }, - }) - .get("/orgs/myorg") - .reply(200, {}); - - const octokit = new Octokit({ - baseUrl: "https://authentication-test-host.com", - log: { - warn: () => {}, - }, - }); - - octokit.authenticate({ - type: "basic", - username: "username", - password: "password", - on2fa() { - return 123456; - }, - }); - - return octokit.rest.orgs.get({ org: "myorg" }); - }); - - it("octokit.authenticate(): basic with async 2fa", () => { - nock("https://authentication-test-host.com", { - reqheaders: { - authorization: "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", - }, - }) - .get("/orgs/myorg") - .reply( - 401, - {}, - { - "x-github-otp": "required; app", - }, - ); - - nock("https://authentication-test-host.com", { - reqheaders: { - authorization: "Basic dXNlcm5hbWU6cGFzc3dvcmQ=", - "x-github-otp": "123456", - }, - }) - .get("/orgs/myorg") - .reply(200, {}); - - const octokit = new Octokit({ - baseUrl: "https://authentication-test-host.com", - log: { - warn: () => {}, - }, - }); - - octokit.authenticate({ - type: "basic", - username: "username", - password: "password", - on2fa() { - return Promise.resolve(123456); - }, + expect(warnCalledCount).toStrictEqual(1); }); - - return octokit.rest.orgs.get({ org: "myorg" }); }); it("octokit.authenticate(): basic with 2fa and invalid one-time-password", () => { @@ -378,7 +130,7 @@ describe("deprecations", () => { }) .catch((error) => { - expect(error.message).to.match(/Invalid one-time password/i); + expect(error.message).toMatch(/Invalid one-time password/i); }); }); @@ -416,12 +168,12 @@ describe("deprecations", () => { throw new Error('should fail with "on2fa missing" error'); }) .catch((error) => { - expect(error.message).to.equal( + expect(error.message).toStrictEqual( "2FA required, but options.on2fa is not a function. See https://github.com/octokit/rest.js#authentication", ); - expect(error.status).to.equal(401); - expect(!!error.response.headers).to.equal(true); - expect(!!error.request).to.equal(true); + expect(error.status).toStrictEqual(401); + expect(!!error.response.headers).toStrictEqual(true); + expect(!!error.request).toStrictEqual(true); }); }); @@ -582,19 +334,19 @@ describe("deprecations", () => { expect(() => { octokit.authenticate({}); - }).to.throw(Error); + }).toThrow(Error); expect(() => { octokit.authenticate({ type: "basic" }); - }).to.throw(Error); + }).toThrow(Error); expect(() => { octokit.authenticate({ type: "oauth" }); - }).to.throw(Error); + }).toThrow(Error); expect(() => { octokit.authenticate({ type: "token" }); - }).to.throw(Error); + }).toThrow(Error); }); it('octokit.authenticate() when "auth" option is set', () => { @@ -613,7 +365,7 @@ describe("deprecations", () => { token: "secret123", }); - expect(warnCalledWith).to.match( + expect(warnCalledWith).toMatch( /octokit\.authenticate\(\) is deprecated and has no effect/, ); }); @@ -647,12 +399,12 @@ describe("deprecations", () => { .get({ org: "myorg" }) .then(() => { // deprecation is only logged once per process, I couldn't figure out how to reset the counter - // expect(warnCalledCount).to.equal(1); + // expect(warnCalledCount).toStrictEqual(1); return octokit.auth(); }) .then((authentication) => { - expect(authentication).to.deep.equal({ + expect(authentication).toStrictEqual({ type: "deprecated", message: 'Setting the "new Octokit({ auth })" option to an object without also setting the "authStrategy" option is deprecated and will be removed in v17. See (https://octokit.github.io/rest.js/#authentication)', @@ -687,7 +439,7 @@ describe("deprecations", () => { return octokit.rest.orgs.get({ org: "myorg" }).then(() => { // deprecation is only logged once per process, I couldn't figure out how to reset the counter - // expect(warnCalledCount).to.equal(1); + // expect(warnCalledCount).toStrictEqual(1); }); }); @@ -716,7 +468,7 @@ describe("deprecations", () => { return octokit.rest.orgs.get({ org: "myorg" }).then(() => { // deprecation is only logged once per process, I couldn't figure out how to reset the counter - // expect(warnCalledCount).to.equal(1); + // expect(warnCalledCount).toStrictEqual(1); }); }); @@ -868,7 +620,7 @@ describe("deprecations", () => { }) .catch((error) => { - expect(error.message).to.match(/Invalid one-time password/i); + expect(error.message).toMatch(/Invalid one-time password/i); }); }); @@ -936,7 +688,7 @@ describe("deprecations", () => { .request("/") .then(() => octokit.request("/")) .then(() => { - expect(callCount).to.equal(2); + expect(callCount).toStrictEqual(2); }); }); @@ -971,12 +723,12 @@ describe("deprecations", () => { }) .catch((error) => { - expect(error.message).to.equal( + expect(error.message).toStrictEqual( "2FA required, but options.on2fa is not a function. See https://github.com/octokit/rest.js#authentication", ); - expect(error.status).to.equal(401); - expect(!!error.response.headers).to.equal(true); - expect(!!error.request).to.equal(true); + expect(error.status).toStrictEqual(401); + expect(!!error.response.headers).toStrictEqual(true); + expect(!!error.request).toStrictEqual(true); }); }); @@ -1061,7 +813,7 @@ describe("deprecations", () => { throw new Error("should not resolve"); }) .catch((error) => { - expect(error.message).to.equal("test"); + expect(error.message).toStrictEqual("test"); }); }); @@ -1172,52 +924,6 @@ describe("deprecations", () => { return octokit.request("/"); }); - it("options.auth=() => bearer without prefix", () => { - nock("https://authentication-test-host.com", { - reqheaders: { - authorization: - "bearer eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NTM4MTkzMTIsImV4cCI6MTU1MzgxOTM3MiwiaXNzIjoxfQ.etiSZ4LFQZ8tiMGJVqKDoGn8hxMCgwL4iLvU5xBUqbAPr4pbk_jJZmMQjuxTlOnRxq4e7NouTizGCdfohRMb3R1mpLzGPzOH9_jqSA_BWYxolsRP_WDSjuNcw6nSxrPRueMVRBKFHrqcTOZJej0djRB5pI61hDZJ_-DGtiOIFexlK3iuVKaqBkvJS5-TbTekGuipJ652g06gXuz-l8i0nHiFJldcuIruwn28hTUrjgtPbjHdSBVn_QQLKc2Fhij8OrhcGqp_D_fvb_KovVmf1X6yWiwXV5VXqWARS-JGD9JTAr2495ZlLV_E4WPxdDpz1jl6XS9HUhMuwBpaCOuipw", - }, - }) - .get("/app") - .reply(200, {}); - - const octokit = new Octokit({ - baseUrl: "https://authentication-test-host.com", - auth: () => - "eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJpYXQiOjE1NTM4MTkzMTIsImV4cCI6MTU1MzgxOTM3MiwiaXNzIjoxfQ.etiSZ4LFQZ8tiMGJVqKDoGn8hxMCgwL4iLvU5xBUqbAPr4pbk_jJZmMQjuxTlOnRxq4e7NouTizGCdfohRMb3R1mpLzGPzOH9_jqSA_BWYxolsRP_WDSjuNcw6nSxrPRueMVRBKFHrqcTOZJej0djRB5pI61hDZJ_-DGtiOIFexlK3iuVKaqBkvJS5-TbTekGuipJ652g06gXuz-l8i0nHiFJldcuIruwn28hTUrjgtPbjHdSBVn_QQLKc2Fhij8OrhcGqp_D_fvb_KovVmf1X6yWiwXV5VXqWARS-JGD9JTAr2495ZlLV_E4WPxdDpz1jl6XS9HUhMuwBpaCOuipw", - }); - - return octokit.request("/app"); - }); - - // deprecated client options - it("agent option", () => { - let warnCalled = false; - const octokit = new Octokit({ - agent: "agent", - log: { - warn: () => { - warnCalled = true; - }, - }, - }); - - octokit.hook.wrap("request", (request, options) => { - expect(options.request.agent).to.equal("agent"); - return "ok"; - }); - - expect(warnCalled).to.equal(true); - - return octokit - .request("/") - - .then((response) => { - expect(response).to.equal("ok"); - }); - }); - it("timeout option", () => { let warnCallCount = 0; const octokit = new Octokit({ @@ -1228,65 +934,26 @@ describe("deprecations", () => { }, }, }); - Octokit({ - timeout: 456, - log: { - warn: () => { - warnCallCount++; - }, - }, - }); octokit.hook.wrap("request", (request, options) => { - expect(options.request.timeout).to.equal(123); + expect(options.request.timeout).toStrictEqual(123); return "ok"; }); - expect(warnCallCount).to.equal(1); + expect(warnCallCount).toStrictEqual(1); return octokit .request("/") .then((response) => { - expect(response).to.equal("ok"); - }); - }); - - it('headers["User-Agent"] option', () => { - let warnCalled = false; - const octokit = new Octokit({ - headers: { - "User-Agent": "blah", - }, - log: { - warn: () => { - warnCalled = true; - }, - }, - }); - - octokit.hook.wrap("request", (request, options) => { - expect(options.headers["user-agent"]).to.match( - /^blah octokit\.js\/0\.0\.0-development /, - ); - return "ok"; - }); - - expect(warnCalled).to.equal(true); - - return octokit - .request("/") - - .then((response) => { - expect(response).to.equal("ok"); + expect(response).toStrictEqual("ok"); }); }); it("headers.accept option", () => { const octokit = new Octokit({ headers: { - accept: - "application/vnd.github.jean-grey-preview+json,application/vnd.github.symmetra-preview+json", + accept: "application/vnd.github.v3+json", }, log: { warn: () => {}, @@ -1294,8 +961,8 @@ describe("deprecations", () => { }); octokit.hook.wrap("request", (request, options) => { - expect(options.headers.accept).to.equal( - "application/vnd.github.jean-grey-preview+json,application/vnd.github.symmetra-preview+json", + expect(options.headers.accept).toStrictEqual( + "application/vnd.github.v3+json", ); return "ok"; }); @@ -1304,7 +971,7 @@ describe("deprecations", () => { .request("/") .then((response) => { - expect(response).to.equal("ok"); + expect(response).toStrictEqual("ok"); }); }); @@ -1410,30 +1077,31 @@ describe("deprecations", () => { "accept-encoding": "", }, }); - const listReposOptions = octokit.rest.apps.listRepos.endpoint.merge({ - per_page: 1, - }); + const listReposOptions = + octokit.rest.apps.listReposAccessibleToInstallation.endpoint.merge({ + per_page: 1, + }); return octokit .paginate(listReposOptions, (result) => { - expect(result.data.incomplete_results).to.equal(undefined); - expect(result.data.repository_selection).to.equal("all"); - expect(result.data.total_count).to.equal(2); - expect(result.data.repositories.length).to.equal(1); + expect(result.data.incomplete_results).toStrictEqual(undefined); + expect(result.data.repository_selection).toStrictEqual("all"); + expect(result.data.total_count).toStrictEqual(2); + expect(result.data.repositories.length).toStrictEqual(1); return result; }) .then(() => octokit.paginate(searchOptions, (result) => { - expect(result.data.incomplete_results).to.equal(false); - expect(result.data.total_count).to.equal(2); - expect(result.data.items.length).to.equal(1); + expect(result.data.incomplete_results).toStrictEqual(false); + expect(result.data.total_count).toStrictEqual(2); + expect(result.data.items.length).toStrictEqual(1); return result; }), ) .then(() => { - expect(warnCallCount).to.equal(4); + expect(warnCallCount).toStrictEqual(4); }); }); }); diff --git a/test/integration/pagination-test.js b/test/integration/pagination.test.js similarity index 90% rename from test/integration/pagination-test.js rename to test/integration/pagination.test.js index 8d34f3a7..ed6d1707 100644 --- a/test/integration/pagination-test.js +++ b/test/integration/pagination.test.js @@ -1,6 +1,6 @@ -const nock = require("nock"); +import nock from "nock"; -const { Octokit } = require("../../"); +import { Octokit } from "../../pkg/dist-src/index.js"; describe("pagination", () => { it(".paginate()", () => { @@ -24,14 +24,14 @@ describe("pagination", () => { octokit .paginate("GET /organizations", { per_page: 1 }) .then((organizations) => { - expect(organizations).to.deep.equal([{ id: 1 }, { id: 2 }]); + expect(organizations).toStrictEqual([{ id: 1 }, { id: 2 }]); }), octokit .paginate("GET /organizations", { per_page: 1 }, (response) => response.data.map((org) => org.id), ) .then((organizations) => { - expect(organizations).to.deep.equal([1, 2]); + expect(organizations).toStrictEqual([1, 2]); }), octokit .paginate( @@ -43,7 +43,7 @@ describe("pagination", () => { (response) => response.data.map((org) => org.id), ) .then((organizations) => { - expect(organizations).to.deep.equal([1, 2]); + expect(organizations).toStrictEqual([1, 2]); }), ]); }); @@ -67,7 +67,7 @@ describe("pagination", () => { return octokit .paginate("GET /organizations", { per_page: 1 }, (response) => undefined) .then((results) => { - expect(results).to.deep.equal([undefined, undefined]); + expect(results).toStrictEqual([undefined, undefined]); }); }); @@ -93,7 +93,7 @@ describe("pagination", () => { return response.data.map((org) => org.id); }) .then((organizations) => { - expect(organizations).to.deep.equal([1]); + expect(organizations).toStrictEqual([1]); }); }); @@ -116,7 +116,7 @@ describe("pagination", () => { return octokit .paginate("GET /organizations", { per_page: 1 }) .then((organizations) => { - expect(organizations).to.deep.equal([{ id: 1 }, { id: 2 }]); + expect(organizations).toStrictEqual([{ id: 1 }, { id: 2 }]); }); }); @@ -154,7 +154,7 @@ describe("pagination", () => { request: { paginate: true }, }) .then((organizations) => { - expect(organizations).to.deep.equal([{ id: 1 }, { id: 2 }]); + expect(organizations).toStrictEqual([{ id: 1 }, { id: 2 }]); }); }); @@ -176,7 +176,7 @@ describe("pagination", () => { [Symbol.asyncIterator](); return iterator.next().then((result) => { - expect(result.value.data.foo).to.equal("bar"); + expect(result.value.data.foo).toStrictEqual("bar"); }); }); @@ -235,7 +235,7 @@ describe("pagination", () => { }); return octokit.paginate(options).then((results) => { - expect(results).to.deep.equal([{ id: "123" }, { id: "456" }]); + expect(results).toStrictEqual([{ id: "123" }, { id: "456" }]); }); }); @@ -282,12 +282,13 @@ describe("pagination", () => { ); const octokit = new Octokit(); - const options = octokit.rest.apps.listRepos.endpoint.merge({ - per_page: 1, - }); + const options = + octokit.rest.apps.listReposAccessibleToInstallation.endpoint.merge({ + per_page: 1, + }); return octokit.paginate(options).then((results) => { - expect(results).to.deep.equal([{ id: "123" }, { id: "456" }]); + expect(results).toStrictEqual([{ id: "123" }, { id: "456" }]); }); }); @@ -339,7 +340,7 @@ describe("pagination", () => { }); return octokit.paginate(options).then((results) => { - expect(results).to.deep.equal([{ id: "123" }, { id: "456" }]); + expect(results).toStrictEqual([{ id: "123" }, { id: "456" }]); }); }); @@ -359,12 +360,13 @@ describe("pagination", () => { }); const octokit = new Octokit(); - const options = octokit.rest.apps.listRepos.endpoint.merge({ - per_page: 1, - }); + const options = + octokit.rest.apps.listReposAccessibleToInstallation.endpoint.merge({ + per_page: 1, + }); return octokit.paginate(options).then((results) => { - expect(results).to.deep.equal([{ id: "123" }]); + expect(results).toStrictEqual([{ id: "123" }]); }); }); @@ -385,7 +387,7 @@ describe("pagination", () => { }); return octokit.paginate(options).then((result) => { - expect(result[0].state).to.equal("success"); + expect(result[0].state).toStrictEqual("success"); }); }); }); diff --git a/test/integration/params-validations-test.js b/test/integration/params-validations.test.js similarity index 79% rename from test/integration/params-validations-test.js rename to test/integration/params-validations.test.js index be9517b3..0eb02733 100644 --- a/test/integration/params-validations-test.js +++ b/test/integration/params-validations.test.js @@ -1,6 +1,6 @@ -const nock = require("nock"); +import nock from "nock"; -const { Octokit } = require("../../"); +import { Octokit } from "../../pkg/dist-src/index.js"; describe("params validations", () => { it("octokit.rest.orgs.get({})", () => { @@ -14,10 +14,10 @@ describe("params validations", () => { }) .catch((error) => { - expect(error.message).to.equal( + expect(error.message).toStrictEqual( "Empty value for parameter 'org': undefined", ); - expect(error.status).to.equal(400); + expect(error.status).toStrictEqual(400); }); }); @@ -34,8 +34,8 @@ describe("params validations", () => { }) .catch((error) => { - expect(error.status).to.equal(500); - expect(error.message).to.equal( + expect(error.status).toStrictEqual(500); + expect(error.message).toStrictEqual( "request to https://127.0.0.1:8/orgs/foo failed, reason: connect ECONNREFUSED 127.0.0.1:8", ); }); @@ -52,8 +52,8 @@ describe("params validations", () => { }) .catch((error) => { - expect(error.status).to.equal(400); - expect(error.message).to.equal( + expect(error.status).toStrictEqual(400); + expect(error.message).toStrictEqual( "Invalid value for parameter 'filter': \"foo\"", ); }); @@ -70,8 +70,8 @@ describe("params validations", () => { }) .catch((error) => { - expect(error.status).to.equal(400); - expect(error.message).to.equal( + expect(error.status).toStrictEqual(400); + expect(error.message).toStrictEqual( "Invalid value for parameter 'position': \"foo\"", ); }); @@ -90,18 +90,18 @@ describe("params validations", () => { }) .catch((error) => { - expect(error.status).to.equal(400); - expect(error.message).to.equal( + expect(error.status).toStrictEqual(400); + expect(error.message).toStrictEqual( "Invalid value for parameter 'position': \"Age Ain’t Nothing\" is NaN", ); }); }); - it("Not a valid JSON string for octokit.rest.repos.createHook({..., config})", () => { + it("Not a valid JSON string for octokit.rest.repos.createWebhook({..., config})", () => { const octokit = new Octokit(); return octokit.rest.repos - .createHook({ + .createWebhook({ owner: "foo", repo: "bar", name: "captain", @@ -113,8 +113,8 @@ describe("params validations", () => { }) .catch((error) => { - expect(error.status).to.equal(400); - expect(error.message).to.equal( + expect(error.status).toStrictEqual(400); + expect(error.message).toStrictEqual( "JSON parse error of value for parameter 'config': \"I’m no Je-Son!\"", ); }); @@ -127,7 +127,7 @@ describe("params validations", () => { nock("https://milestones-test-host.com") .post("/repos/foo/bar/milestones", (body) => { - expect(body.due_on).to.equal("2012-10-09T23:39:01.000Z"); + expect(body.due_on).toStrictEqual("2012-10-09T23:39:01.000Z"); return true; }) .reply(201, {}); @@ -148,21 +148,21 @@ describe("params validations", () => { nock("https://notifications-test-host.com") .get("/notifications") .query((query) => { - expect(query).to.eql({ + expect(query).toStrictEqual({ since: "2018-01-21T23:27:31.000Z", }); return true; }) .reply(200, {}); - return octokit.rest.activity.listNotifications({ + return octokit.rest.activity.listNotificationsForAuthenticatedUser({ since: "2018-01-21T23:27:31.000Z", }); }); it("octokit.rest.gitdata.createTree() with invalid tree[] object", () => { const octokit = new Octokit(); - return octokit.rest.gitdata + return octokit.rest.git .createTree({ owner: "foo", repo: "bar", @@ -179,8 +179,8 @@ describe("params validations", () => { }) .catch((error) => { - expect(error.status).to.equal(400); - expect(error.message).to.equal( + expect(error.status).toStrictEqual(400); + expect(error.message).toStrictEqual( "Invalid value for parameter 'tree[0].type': \"foo\"", ); }); @@ -202,8 +202,8 @@ describe("params validations", () => { }) .catch((error) => { - expect(error.status).to.equal(400); - expect(error.message).to.equal("'description' cannot be null"); + expect(error.status).toStrictEqual(400); + expect(error.message).toStrictEqual("'description' cannot be null"); }); }); @@ -226,7 +226,7 @@ describe("params validations", () => { // ignore error }) .then(() => { - expect(options).to.deep.eql({ + expect(options).toStrictEqual({ org: "foo", headers: { "x-bar": "baz", diff --git a/test/integration/plugins-test.js b/test/integration/plugins.test.js similarity index 75% rename from test/integration/plugins-test.js rename to test/integration/plugins.test.js index b88d890d..31703b51 100644 --- a/test/integration/plugins-test.js +++ b/test/integration/plugins.test.js @@ -1,4 +1,4 @@ -const { Octokit } = require("../../"); +import { Octokit } from "../../pkg/dist-src/index.js"; describe("plugins", () => { it("gets called in constructor", () => { @@ -6,7 +6,7 @@ describe("plugins", () => { octokit.foo = "bar"; }); const myClient = new MyOctokit(); - expect(myClient.foo).to.equal("bar"); + expect(myClient.foo).toStrictEqual("bar"); }); it("does not override plugins of original constructor", () => { @@ -14,15 +14,15 @@ describe("plugins", () => { octokit.foo = "bar"; }); const myClient = new MyOctokit(); - expect(myClient.foo).to.equal("bar"); + expect(myClient.foo).toStrictEqual("bar"); const octokit = new Octokit(); - expect(octokit.foo).to.equal(undefined); + expect(octokit.foo).toStrictEqual(undefined); }); it("receives client options", () => { const MyOctokit = Octokit.plugin((octokit, options) => { - expect(options.foo).to.equal("bar"); + expect(options.foo).toStrictEqual("bar"); }); new MyOctokit({ foo: "bar" }); }); @@ -36,6 +36,6 @@ describe("plugins", () => { } }; const MyOctokit = Octokit.plugin(myPlugin).plugin(myPlugin); - expect(() => new MyOctokit()).to.not.throw(); + expect(() => new MyOctokit()).not.toThrow(); }); }); diff --git a/test/integration/register-endpoints-test.js b/test/integration/register-endpoints-test.js deleted file mode 100644 index a1df8432..00000000 --- a/test/integration/register-endpoints-test.js +++ /dev/null @@ -1,61 +0,0 @@ -const nock = require("nock"); - -const { Octokit } = require("../../"); - -describe("registerEndpoints", () => { - it("optins are not altered in registered endpoint methods", () => { - nock("https://api.github.com") - .get("/repos/octocat/hello-world/issues/123") - .reply(200, {}); - - const octokit = new Octokit({ - log: { - warn: () => {}, - }, - }); - - octokit.registerEndpoints({ - foo: { - bar: { - method: "GET", - params: { - issue_number: { - required: true, - type: "integer", - }, - number: { - alias: "issue_number", - deprecated: true, - type: "integer", - }, - owner: { - required: true, - type: "string", - }, - repo: { - required: true, - type: "string", - }, - }, - url: "/repos/{owner}/{repo}/issues/{issue_number}", - }, - }, - }); - - const options = { - owner: "octocat", - repo: "hello-world", - number: 123, - }; - - const promise = octokit.foo.bar(options); - - expect(options).to.deep.equal({ - owner: "octocat", - repo: "hello-world", - number: 123, - }); - - return promise; - }); -}); diff --git a/test/integration/request-errors-test.js b/test/integration/request-errors.test.js similarity index 69% rename from test/integration/request-errors-test.js rename to test/integration/request-errors.test.js index 22dd4b3e..6ee8342a 100644 --- a/test/integration/request-errors-test.js +++ b/test/integration/request-errors.test.js @@ -1,6 +1,7 @@ -const nock = require("nock"); +import nock from "nock"; +import { expect, describe, it } from "@jest/globals"; -const { Octokit } = require("../../"); +import { Octokit } from "../../pkg/dist-src/index.js"; describe("request errors", () => { it("timeout", () => { @@ -21,9 +22,9 @@ describe("request errors", () => { }) .catch((error) => { - expect(error.name).to.equal("HttpError"); - expect(error.status).to.equal(500); - expect(error.message).to.match(/timeout/); + expect(error.name).toStrictEqual("HttpError"); + expect(error.status).toStrictEqual(500); + expect(error.message).toMatch(/timeout/); }); }); @@ -40,9 +41,9 @@ describe("request errors", () => { .get({ org: "myorg" }) .catch((error) => { - expect(error.name).to.equal("HttpError"); - expect(error.status).to.equal(500); - expect(error).to.have.property("stack"); + expect(error.name).toStrictEqual("HttpError"); + expect(error.status).toStrictEqual(500); + expect(error.stack).not.toBeUndefined(); }); }); @@ -59,9 +60,9 @@ describe("request errors", () => { .get({ org: "myorg" }) .catch((error) => { - expect(error.name).to.equal("HttpError"); - expect(error.status).to.equal(404); - expect(error).to.have.property("stack"); + expect(error.name).toStrictEqual("HttpError"); + expect(error.status).toStrictEqual(404); + expect(error.stack).not.toBeUndefined(); }); }); @@ -76,9 +77,9 @@ describe("request errors", () => { .get({ org: "myorg" }) .catch((error) => { - expect(error.name).to.equal("HttpError"); - expect(error.status).to.equal(401); - expect(error).to.have.property("stack"); + expect(error.name).toStrictEqual("HttpError"); + expect(error.status).toStrictEqual(401); + expect(error.stack).not.toBeUndefined(); }); }); @@ -99,9 +100,9 @@ describe("request errors", () => { .get({ org: "myorg" }) .catch((error) => { - expect(error.name).to.equal("HttpError"); - expect(error.status).to.equal(401); - expect(error.response.headers).to.deep.equal({ + expect(error.name).toStrictEqual("HttpError"); + expect(error.status).toStrictEqual(401); + expect(error.response.headers).toStrictEqual({ "content-type": "application/json", "x-foo": "bar", }); @@ -120,7 +121,7 @@ describe("request errors", () => { .request("/") .catch((error) => { - expect(error.request.headers.authorization).to.equal( + expect(error.request.headers.authorization).toStrictEqual( "token [REDACTED]", ); }); diff --git a/test/issues/1134-missing-endpoint-scopes-test.js b/test/issues/1134-missing-endpoint-scopes.test.js similarity index 55% rename from test/issues/1134-missing-endpoint-scopes-test.js rename to test/issues/1134-missing-endpoint-scopes.test.js index 2d62fcaa..c65363eb 100644 --- a/test/issues/1134-missing-endpoint-scopes-test.js +++ b/test/issues/1134-missing-endpoint-scopes.test.js @@ -1,8 +1,8 @@ -const { Octokit } = require("../../"); +import { Octokit } from "../../pkg/dist-src/index.js"; describe("https://github.com/octokit/rest.js/issues/1134", () => { it("octokit.rest.pulls", () => { const octokit = new Octokit(); - expect(octokit.rest.pulls).to.be.an("object"); + expect(typeof octokit.rest.pulls).toStrictEqual("object"); }); }); diff --git a/test/issues/1279-store-otp-send-header-all-requests-test.js b/test/issues/1279-store-otp-send-header-all-requests.test.js similarity index 94% rename from test/issues/1279-store-otp-send-header-all-requests-test.js rename to test/issues/1279-store-otp-send-header-all-requests.test.js index 4820291d..4c8243fe 100644 --- a/test/issues/1279-store-otp-send-header-all-requests-test.js +++ b/test/issues/1279-store-otp-send-header-all-requests.test.js @@ -1,5 +1,5 @@ -const nock = require("nock"); -const { Octokit } = require("../../"); +import nock from "nock"; +import { Octokit } from "../../pkg/dist-src/index.js"; describe("https://github.com/octokit/rest.js/issues/1279", () => { it("2fa code gets stored and passed as header to listAuthorizations", () => { @@ -114,11 +114,11 @@ describe("https://github.com/octokit/rest.js/issues/1279", () => { }); return octokit.request("/").then(() => { - expect(on2faCalledCounter).to.equal(1); + expect(on2faCalledCounter).toStrictEqual(1); return octokit.authorization .listAuthorizations({ per_page: 100 }) .then(() => { - expect(on2faCalledCounter).to.equal(2); + expect(on2faCalledCounter).toStrictEqual(2); }); }); }); diff --git a/test/issues/1323-parameter-deprecation-bug-test.js b/test/issues/1323-parameter-deprecation-bug.test.js similarity index 82% rename from test/issues/1323-parameter-deprecation-bug-test.js rename to test/issues/1323-parameter-deprecation-bug.test.js index 7b296dab..77b6612d 100644 --- a/test/issues/1323-parameter-deprecation-bug-test.js +++ b/test/issues/1323-parameter-deprecation-bug.test.js @@ -1,5 +1,5 @@ -const nock = require("nock"); -const { Octokit } = require("../.."); +import nock from "nock"; +import { Octokit } from "../../pkg/dist-src/index.js"; describe("https://github.com/octokit/rest.js/issues/1323", () => { it("should accept new parameter", () => { diff --git a/test/issues/1497-include-error-message-on-validation-error-test.js b/test/issues/1497-include-error-message-on-validation-error.test.js similarity index 84% rename from test/issues/1497-include-error-message-on-validation-error-test.js rename to test/issues/1497-include-error-message-on-validation-error.test.js index 802e60bb..2af2289d 100644 --- a/test/issues/1497-include-error-message-on-validation-error-test.js +++ b/test/issues/1497-include-error-message-on-validation-error.test.js @@ -1,12 +1,11 @@ -const nock = require("nock"); -const { Octokit } = require("../../"); +import nock from "nock"; +import { Octokit } from "../../pkg/dist-src/index.js"; describe("https://github.com/octokit/rest.js/issues/1497", () => { it("octokit.rest.repos.updateBranchProtection()", () => { nock("https://request-errors-test.com", { reqheaders: { - accept: - "application/vnd.github.hellcat-preview+json,application/vnd.github.luke-cage-preview+json,application/vnd.github.zzzax-preview+json", + accept: "application/vnd.github.v3", authorization: "token secret123", }, }) @@ -36,7 +35,6 @@ describe("https://github.com/octokit/rest.js/issues/1497", () => { }); return octokit.rest.repos .updateBranchProtection({ - mediaType: { previews: ["hellcat", "luke-cage", "zzzax"] }, owner: "gr2m", repo: "sandbox", branch: "gr2m-patch-1", @@ -54,8 +52,7 @@ describe("https://github.com/octokit/rest.js/issues/1497", () => { expect.fail("This should throw error."); }) .catch((error) => { - expect(error).to.have.property( - "message", + expect(error.message).toStrictEqual( `Validation Failed: "Only organization repositories can have users and team restrictions"`, ); }); diff --git a/test/issues/1553-deprecated-teams-methods-test.js b/test/issues/1553-deprecated-teams-methods-test.js deleted file mode 100644 index 28a311ea..00000000 --- a/test/issues/1553-deprecated-teams-methods-test.js +++ /dev/null @@ -1,27 +0,0 @@ -const nock = require("nock"); -const { Octokit } = require("../../"); - -describe("https://github.com/octokit/rest.js/issues/1553", () => { - it.skip("octokit.rest.teams.removeMember()", () => { - const octokit = new Octokit(); - expect(typeof octokit.rest.teams.removeMember).to.equal("function"); - }); - it.skip("octokit.rest.teams.removeMembership()", () => { - const octokit = new Octokit(); - expect(typeof octokit.rest.teams.removeMembership).to.equal("function"); - }); - it.skip("octokit.rest.teams.listMembers()", () => { - const octokit = new Octokit(); - expect(typeof octokit.rest.teams.listMembers).to.equal("function"); - }); - it.skip("octokit.rest.teams.listMembers.endpoint()", () => { - const octokit = new Octokit(); - expect(typeof octokit.rest.teams.listMembers.endpoint).to.equal("function"); - }); - it.skip("octokit.rest.teams.listMembersLegacy.endpoint()", () => { - const octokit = new Octokit(); - expect(typeof octokit.rest.teams.listMembersLegacy.endpoint).to.equal( - "function", - ); - }); -}); diff --git a/test/issues/765-remove-milestone-from-issue-test.js b/test/issues/765-remove-milestone-from-issue.test.js similarity index 77% rename from test/issues/765-remove-milestone-from-issue-test.js rename to test/issues/765-remove-milestone-from-issue.test.js index c35e18b1..3f97f6da 100644 --- a/test/issues/765-remove-milestone-from-issue-test.js +++ b/test/issues/765-remove-milestone-from-issue.test.js @@ -1,11 +1,11 @@ -const nock = require("nock"); -const { Octokit } = require("../../"); +import nock from "nock"; +import { Octokit } from "../../pkg/dist-src/index.js"; describe("https://github.com/octokit/rest.js/issues/765", () => { it("octokit.rest.issues.update({..., milestone: null})", () => { nock("https://api.github.com") .patch("/repos/epmatsw/example-repo/issues/1", (body) => { - expect(body).to.deep.equal({ milestone: null }); + expect(body).toStrictEqual({ milestone: null }); return true; }) .reply(200, {}); diff --git a/test/issues/818-get-installations-test.js b/test/issues/818-get-installations.test.js similarity index 78% rename from test/issues/818-get-installations-test.js rename to test/issues/818-get-installations.test.js index 0a82f083..064f9444 100644 --- a/test/issues/818-get-installations-test.js +++ b/test/issues/818-get-installations.test.js @@ -1,5 +1,5 @@ -const nock = require("nock"); -const { Octokit } = require("../../"); +import nock from "nock"; +import { Octokit } from "../../pkg/dist-src/index.js"; describe("https://github.com/octokit/rest.js/issues/818", () => { it("octokit.rest.apps.listInstallations()", () => { diff --git a/test/issues/826-fail-on-304-test.js b/test/issues/826-fail-on-304.test.js similarity index 81% rename from test/issues/826-fail-on-304-test.js rename to test/issues/826-fail-on-304.test.js index c6af4d41..069abab7 100644 --- a/test/issues/826-fail-on-304-test.js +++ b/test/issues/826-fail-on-304.test.js @@ -1,5 +1,5 @@ -const nock = require("nock"); -const { Octokit } = require("../../"); +import nock from "nock"; +import { Octokit } from "../../pkg/dist-src/index.js"; describe("https://github.com/octokit/rest.js/issues/826", () => { it("throws error on 304 responses", () => { @@ -19,7 +19,7 @@ describe("https://github.com/octokit/rest.js/issues/826", () => { expect.fail("should throw error"); }) .catch((error) => { - expect(error.status).to.equal(304); + expect(error.status).toStrictEqual(304); }); }); }); diff --git a/test/issues/841-head-request-test.js b/test/issues/841-head-request.test.js similarity index 89% rename from test/issues/841-head-request-test.js rename to test/issues/841-head-request.test.js index 50a61d8d..0fd5d9fc 100644 --- a/test/issues/841-head-request-test.js +++ b/test/issues/841-head-request.test.js @@ -1,5 +1,5 @@ -const nock = require("nock"); -const { Octokit } = require("../../"); +import nock from "nock"; +import { Octokit } from "../../pkg/dist-src/index.js"; describe("https://github.com/octokit/rest.js/issues/841", () => { it("supports sending GET requests with method: HEAD", () => { @@ -40,7 +40,7 @@ describe("https://github.com/octokit/rest.js/issues/841", () => { }) .catch((error) => { - expect(error.status).to.equal(404); + expect(error.status).toStrictEqual(404); }); }); }); diff --git a/test/issues/861-custom-accept-header-test.js b/test/issues/861-custom-accept-header.test.js similarity index 91% rename from test/issues/861-custom-accept-header-test.js rename to test/issues/861-custom-accept-header.test.js index 85626caa..69c7df94 100644 --- a/test/issues/861-custom-accept-header-test.js +++ b/test/issues/861-custom-accept-header.test.js @@ -1,5 +1,5 @@ -const nock = require("nock"); -const { Octokit } = require("../../"); +import nock from "nock"; +import { Octokit } from "../../pkg/dist-src/index.js"; describe("https://github.com/octokit/rest.js/issues/861", () => { it("custom accept header", () => { diff --git a/test/issues/922-create-check-with-empty-actions-array-test.js b/test/issues/922-create-check-with-empty-actions-array.test.js similarity index 88% rename from test/issues/922-create-check-with-empty-actions-array-test.js rename to test/issues/922-create-check-with-empty-actions-array.test.js index 8ffc9197..41ba8237 100644 --- a/test/issues/922-create-check-with-empty-actions-array-test.js +++ b/test/issues/922-create-check-with-empty-actions-array.test.js @@ -1,5 +1,5 @@ -const nock = require("nock"); -const { Octokit } = require("../../"); +import nock from "nock"; +import { Octokit } from "../../pkg/dist-src/index.js"; describe("https://github.com/octokit/rest.js/issues/922", () => { it("octokit.rest.issues.update({..., milestone: null})", () => {