Skip to content

Commit

Permalink
Add/extend tests for integrationType
Browse files Browse the repository at this point in the history
  • Loading branch information
JonnyBnator committed Sep 23, 2024
1 parent da5747b commit 80741e7
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions test/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,46 @@ describe(DiscordStrategy, () => {
);
});

test("should correctly set the integrationType to 0", async () => {
await testDiscordStrategy(
{
scope: ["email", "applications.commands", "identify"],
integrationType: 0,
},
(error) => {
if (!(error instanceof Response)) throw error;
expect(error).toBeInstanceOf(Response);
const location = error.headers.get("Location");

if (!location) throw new Error("No redirect header");

const redirectUrl = new URL(location);

expect(redirectUrl.searchParams.get("integration_type")).toBe("0");
},
);
});

test("should correctly set the integrationType to 1", async () => {
await testDiscordStrategy(
{
scope: ["email", "applications.commands", "identify"],
integrationType: 1,
},
(error) => {
if (!(error instanceof Response)) throw error;
expect(error).toBeInstanceOf(Response);
const location = error.headers.get("Location");

if (!location) throw new Error("No redirect header");

const redirectUrl = new URL(location);

expect(redirectUrl.searchParams.get("integration_type")).toBe("1");
},
);
});

test("should correctly format the authorization URL", async () => {
await testDiscordStrategy({}, (error) => {
if (!(error instanceof Response)) throw error;
Expand Down

0 comments on commit 80741e7

Please sign in to comment.