Skip to content

Commit 1faf254

Browse files
authored
test: update unit tests to match new behaviour from PR#811 (#813)
* test: update unit tests to match new behaviour from PR#811 * chore: update size limits
1 parent b2257d7 commit 1faf254

File tree

3 files changed

+15
-25
lines changed

3 files changed

+15
-25
lines changed

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -141,11 +141,11 @@
141141
},
142142
{
143143
"path": "recipe/session/index.js",
144-
"limit": "19.1kb"
144+
"limit": "19.2kb"
145145
},
146146
{
147147
"path": "recipe/session/prebuiltui.js",
148-
"limit": "22kb"
148+
"limit": "22.1kb"
149149
},
150150
{
151151
"path": "recipe/thirdpartyemailpassword/index.js",
@@ -181,7 +181,7 @@
181181
},
182182
{
183183
"path": "recipe/thirdparty/prebuiltui.js",
184-
"limit": "45kb"
184+
"limit": "46kb"
185185
},
186186
{
187187
"path": "recipe/emailpassword/prebuiltui.js",

test/unit/recipe/session/sessionAuth.test.tsx

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ import SessionContext from "../../../../lib/ts/recipe/session/sessionContext";
88
import { SessionContextType } from "../../../../lib/ts/recipe/session";
99
import { PrimitiveClaim, SessionClaim, useClaimValue } from "../../../../lib/ts/recipe/session";
1010
import * as utils from "supertokens-web-js/utils";
11+
import { WindowHandlerReference } from "supertokens-web-js/utils/windowHandler";
1112

1213
const TestClaim: SessionClaim<string> = new PrimitiveClaim({
1314
id: "st-test-claim",
@@ -71,6 +72,10 @@ jest.spyOn(SuperTokens, "getInstanceOrThrow").mockImplementation(
7172
({
7273
redirectToAuth: (mockRedirectToAuth = jest.fn()),
7374
redirectToUrl: (mockRedirectToUrl = jest.fn()),
75+
appInfo: {
76+
websiteDomain: { getAsStringDangerous: () => "http://localhost:3000" },
77+
apiDomain: { getAsStringDangerous: () => "http://localhost:3001" },
78+
},
7479
} as any)
7580
);
7681
jest.spyOn(Session, "getInstanceOrThrow").mockImplementation(() => MockSession as any);
@@ -83,6 +88,7 @@ describe("SessionAuth", () => {
8388
beforeEach(() => {
8489
jest.clearAllMocks();
8590
SuperTokens.reset();
91+
WindowHandlerReference.init();
8692

8793
setMockResolves({
8894
userId: "mock-user-id",
@@ -504,10 +510,10 @@ describe("SessionAuth", () => {
504510
);
505511

506512
// then
507-
expect(await result.findByText(/^accessTokenPayload:/)).toHaveTextContent(
508-
`accessTokenPayload: ${JSON.stringify(mockAccessTokenPayload)}`
509-
);
513+
// it shouldn't update the context
514+
expect(accessTokenPayloadElement).toHaveTextContent(`accessTokenPayload: ${JSON.stringify({})}`);
510515

516+
// and call redirect
511517
expect(mockRedirectToUrl).toHaveBeenLastCalledWith("/test-redirect", undefined);
512518
});
513519

test/unit/recipe/thirdparty/thirdParty.test.ts

Lines changed: 3 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ describe("ThirdParty", function () {
143143
providers: [{} as any],
144144
},
145145
}).authReact(SuperTokens.getInstanceOrThrow().appInfo, false),
146-
{ message: "Custom provider config should contain id and name attributes" }
146+
{ message: "Custom provider config should contain an id attribute" }
147147
);
148148
});
149149

@@ -159,23 +159,7 @@ describe("ThirdParty", function () {
159159
],
160160
},
161161
}).authReact(SuperTokens.getInstanceOrThrow().appInfo, false),
162-
{ message: "Custom provider config should contain id and name attributes" }
163-
);
164-
});
165-
166-
it("Initializing ThirdParty with Custom provider with empty config should throw", async function () {
167-
assert.throws(
168-
() =>
169-
ThirdParty.init({
170-
signInAndUpFeature: {
171-
providers: [
172-
{
173-
id: "twitch",
174-
} as any,
175-
],
176-
},
177-
}).authReact(SuperTokens.getInstanceOrThrow().appInfo, false),
178-
{ message: "Custom provider config should contain id and name attributes" }
162+
{ message: "Custom provider config should contain an id attribute" }
179163
);
180164
});
181165

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

0 commit comments

Comments
 (0)