Skip to content

Commit

Permalink
test: update unit tests to match new behaviour from PR#811 (#813)
Browse files Browse the repository at this point in the history
* test: update unit tests to match new behaviour from PR#811

* chore: update size limits
  • Loading branch information
porcellus authored Apr 15, 2024
1 parent b2257d7 commit 1faf254
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 25 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,11 @@
},
{
"path": "recipe/session/index.js",
"limit": "19.1kb"
"limit": "19.2kb"
},
{
"path": "recipe/session/prebuiltui.js",
"limit": "22kb"
"limit": "22.1kb"
},
{
"path": "recipe/thirdpartyemailpassword/index.js",
Expand Down Expand Up @@ -181,7 +181,7 @@
},
{
"path": "recipe/thirdparty/prebuiltui.js",
"limit": "45kb"
"limit": "46kb"
},
{
"path": "recipe/emailpassword/prebuiltui.js",
Expand Down
12 changes: 9 additions & 3 deletions test/unit/recipe/session/sessionAuth.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import SessionContext from "../../../../lib/ts/recipe/session/sessionContext";
import { SessionContextType } from "../../../../lib/ts/recipe/session";
import { PrimitiveClaim, SessionClaim, useClaimValue } from "../../../../lib/ts/recipe/session";
import * as utils from "supertokens-web-js/utils";
import { WindowHandlerReference } from "supertokens-web-js/utils/windowHandler";

const TestClaim: SessionClaim<string> = new PrimitiveClaim({
id: "st-test-claim",
Expand Down Expand Up @@ -71,6 +72,10 @@ jest.spyOn(SuperTokens, "getInstanceOrThrow").mockImplementation(
({
redirectToAuth: (mockRedirectToAuth = jest.fn()),
redirectToUrl: (mockRedirectToUrl = jest.fn()),
appInfo: {
websiteDomain: { getAsStringDangerous: () => "http://localhost:3000" },
apiDomain: { getAsStringDangerous: () => "http://localhost:3001" },
},
} as any)
);
jest.spyOn(Session, "getInstanceOrThrow").mockImplementation(() => MockSession as any);
Expand All @@ -83,6 +88,7 @@ describe("SessionAuth", () => {
beforeEach(() => {
jest.clearAllMocks();
SuperTokens.reset();
WindowHandlerReference.init();

setMockResolves({
userId: "mock-user-id",
Expand Down Expand Up @@ -504,10 +510,10 @@ describe("SessionAuth", () => {
);

// then
expect(await result.findByText(/^accessTokenPayload:/)).toHaveTextContent(
`accessTokenPayload: ${JSON.stringify(mockAccessTokenPayload)}`
);
// it shouldn't update the context
expect(accessTokenPayloadElement).toHaveTextContent(`accessTokenPayload: ${JSON.stringify({})}`);

// and call redirect
expect(mockRedirectToUrl).toHaveBeenLastCalledWith("/test-redirect", undefined);
});

Expand Down
22 changes: 3 additions & 19 deletions test/unit/recipe/thirdparty/thirdParty.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ describe("ThirdParty", function () {
providers: [{} as any],
},
}).authReact(SuperTokens.getInstanceOrThrow().appInfo, false),
{ message: "Custom provider config should contain id and name attributes" }
{ message: "Custom provider config should contain an id attribute" }
);
});

Expand All @@ -159,23 +159,7 @@ describe("ThirdParty", function () {
],
},
}).authReact(SuperTokens.getInstanceOrThrow().appInfo, false),
{ message: "Custom provider config should contain id and name attributes" }
);
});

it("Initializing ThirdParty with Custom provider with empty config should throw", async function () {
assert.throws(
() =>
ThirdParty.init({
signInAndUpFeature: {
providers: [
{
id: "twitch",
} as any,
],
},
}).authReact(SuperTokens.getInstanceOrThrow().appInfo, false),
{ message: "Custom provider config should contain id and name attributes" }
{ message: "Custom provider config should contain an id attribute" }
);
});

Expand Down Expand Up @@ -308,7 +292,7 @@ describe("ThirdParty", function () {
providers: [Google.init(), Github.init(), "facebook" as any],
},
}).authReact(SuperTokens.getInstanceOrThrow().appInfo, false),
{ message: "Custom provider config should contain id and name attributes" }
{ message: "Custom provider config should contain an id attribute" }
);
});

Expand Down

0 comments on commit 1faf254

Please sign in to comment.