Skip to content

Commit 844171b

Browse files
authored
test: fix react16 tests (#682)
1 parent b434336 commit 844171b

File tree

4 files changed

+83
-84
lines changed

4 files changed

+83
-84
lines changed

examples/for-tests-react-16/src/AppWithReactDomRouter.js

Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -16,29 +16,28 @@ import { EmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/emailpass
1616
import { PasswordlessPreBuiltUI } from "supertokens-auth-react/recipe/passwordless/prebuiltui";
1717
import { ThirdPartyPreBuiltUI } from "supertokens-auth-react/recipe/thirdparty/prebuiltui";
1818

19-
const authRecipe = window.localStorage.getItem("authRecipe") || "emailpassword";
20-
const emailVerificationMode = window.localStorage.getItem("mode") || "OFF";
19+
function AppWithReactDomRouter(props) {
20+
const authRecipe = window.localStorage.getItem("authRecipe") || "emailpassword";
21+
const emailVerificationMode = window.localStorage.getItem("mode") || "OFF";
2122

22-
let recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
23-
if (authRecipe === "thirdparty") {
24-
recipePreBuiltUIList = [ThirdPartyPreBuiltUI];
25-
} else if (authRecipe === "emailpassword") {
26-
recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
27-
} else if (authRecipe === "both") {
28-
recipePreBuiltUIList = [ThirdPartyPreBuiltUI, EmailPasswordPreBuiltUI];
29-
} else if (authRecipe === "thirdpartyemailpassword") {
30-
recipePreBuiltUIList = [ThirdPartyEmailPasswordPreBuiltUI];
31-
} else if (authRecipe === "passwordless") {
32-
recipePreBuiltUIList = [PasswordlessPreBuiltUI];
33-
} else if (authRecipe === "thirdpartypasswordless") {
34-
recipePreBuiltUIList = [ThirdPartyPasswordlessPreBuiltUI];
35-
}
23+
let recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
24+
if (authRecipe === "thirdparty") {
25+
recipePreBuiltUIList = [ThirdPartyPreBuiltUI];
26+
} else if (authRecipe === "emailpassword") {
27+
recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
28+
} else if (authRecipe === "both") {
29+
recipePreBuiltUIList = [EmailPasswordPreBuiltUI, ThirdPartyPreBuiltUI];
30+
} else if (authRecipe === "thirdpartyemailpassword") {
31+
recipePreBuiltUIList = [ThirdPartyEmailPasswordPreBuiltUI];
32+
} else if (authRecipe === "passwordless") {
33+
recipePreBuiltUIList = [PasswordlessPreBuiltUI];
34+
} else if (authRecipe === "thirdpartypasswordless") {
35+
recipePreBuiltUIList = [ThirdPartyPasswordlessPreBuiltUI];
36+
}
3637

37-
if (emailVerificationMode !== "OFF") {
38-
recipePreBuiltUIList.push(EmailVerificationPreBuiltUI);
39-
}
40-
41-
function AppWithReactDomRouter(props) {
38+
if (emailVerificationMode !== "OFF") {
39+
recipePreBuiltUIList.push(EmailVerificationPreBuiltUI);
40+
}
4241
/**
4342
* For user context tests we add this query param so the additional routes
4443
* dont interfere with other tests

examples/for-tests-react-16/src/AppWithReactDomRouterV5.js

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -11,28 +11,28 @@ import { EmailPasswordPreBuiltUI } from "supertokens-auth-react/recipe/emailpass
1111
import { PasswordlessPreBuiltUI } from "supertokens-auth-react/recipe/passwordless/prebuiltui";
1212
import { ThirdPartyPreBuiltUI } from "supertokens-auth-react/recipe/thirdparty/prebuiltui";
1313

14-
const authRecipe = window.localStorage.getItem("authRecipe") || "emailpassword";
15-
const emailVerificationMode = window.localStorage.getItem("mode") || "OFF";
14+
function AppWithReactDomRouter(props) {
15+
const authRecipe = window.localStorage.getItem("authRecipe") || "emailpassword";
16+
const emailVerificationMode = window.localStorage.getItem("mode") || "OFF";
1617

17-
let recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
18-
if (authRecipe === "thirdparty") {
19-
recipePreBuiltUIList = [ThirdPartyPreBuiltUI];
20-
} else if (authRecipe === "emailpassword") {
21-
recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
22-
} else if (authRecipe === "both") {
23-
recipePreBuiltUIList = [EmailPasswordPreBuiltUI, ThirdPartyPreBuiltUI];
24-
} else if (authRecipe === "thirdpartyemailpassword") {
25-
recipePreBuiltUIList = [ThirdPartyEmailPasswordPreBuiltUI];
26-
} else if (authRecipe === "passwordless") {
27-
recipePreBuiltUIList = [PasswordlessPreBuiltUI];
28-
} else if (authRecipe === "thirdpartypasswordless") {
29-
recipePreBuiltUIList = [ThirdPartyPasswordlessPreBuiltUI];
30-
}
31-
if (emailVerificationMode !== "OFF") {
32-
recipePreBuiltUIList.push(EmailVerificationPreBuiltUI);
33-
}
18+
let recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
19+
if (authRecipe === "thirdparty") {
20+
recipePreBuiltUIList = [ThirdPartyPreBuiltUI];
21+
} else if (authRecipe === "emailpassword") {
22+
recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
23+
} else if (authRecipe === "both") {
24+
recipePreBuiltUIList = [EmailPasswordPreBuiltUI, ThirdPartyPreBuiltUI];
25+
} else if (authRecipe === "thirdpartyemailpassword") {
26+
recipePreBuiltUIList = [ThirdPartyEmailPasswordPreBuiltUI];
27+
} else if (authRecipe === "passwordless") {
28+
recipePreBuiltUIList = [PasswordlessPreBuiltUI];
29+
} else if (authRecipe === "thirdpartypasswordless") {
30+
recipePreBuiltUIList = [ThirdPartyPasswordlessPreBuiltUI];
31+
}
32+
if (emailVerificationMode !== "OFF") {
33+
recipePreBuiltUIList.push(EmailVerificationPreBuiltUI);
34+
}
3435

35-
function AppWithReactDomRouter(props) {
3636
return (
3737
<div className="App">
3838
<Router>

examples/for-tests-react-16/src/AppWithoutRouter.js

Lines changed: 22 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,28 +8,6 @@ import { PasswordlessPreBuiltUI } from "supertokens-auth-react/recipe/passwordle
88
import { ThirdPartyPreBuiltUI } from "supertokens-auth-react/recipe/thirdparty/prebuiltui";
99
import { EmailVerificationPreBuiltUI } from "supertokens-auth-react/recipe/emailverification/prebuiltui";
1010

11-
const authRecipe = window.localStorage.getItem("authRecipe") || "emailpassword";
12-
const emailVerificationMode = window.localStorage.getItem("mode") || "OFF";
13-
14-
let recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
15-
if (authRecipe === "thirdparty") {
16-
recipePreBuiltUIList = [ThirdPartyPreBuiltUI];
17-
} else if (authRecipe === "emailpassword") {
18-
recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
19-
} else if (authRecipe === "both") {
20-
recipePreBuiltUIList = [ThirdPartyPreBuiltUI, EmailPasswordPreBuiltUI];
21-
} else if (authRecipe === "thirdpartyemailpassword") {
22-
recipePreBuiltUIList = [ThirdPartyEmailPasswordPreBuiltUI];
23-
} else if (authRecipe === "passwordless") {
24-
recipePreBuiltUIList = [PasswordlessPreBuiltUI];
25-
} else if (authRecipe === "thirdpartypasswordless") {
26-
recipePreBuiltUIList = [ThirdPartyPasswordlessPreBuiltUI];
27-
}
28-
29-
if (emailVerificationMode !== "OFF") {
30-
recipePreBuiltUIList.push(EmailVerificationPreBuiltUI);
31-
}
32-
3311
function AppWithoutRouter() {
3412
return (
3513
<div className="App">
@@ -42,9 +20,30 @@ function AppWithoutRouter() {
4220
}
4321

4422
function Routing() {
45-
const [, setCurrentPath] = useState(window.location.pathname);
23+
const authRecipe = window.localStorage.getItem("authRecipe") || "emailpassword";
4624
const emailVerificationMode = window.localStorage.getItem("mode") || "OFF";
4725

26+
let recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
27+
if (authRecipe === "thirdparty") {
28+
recipePreBuiltUIList = [ThirdPartyPreBuiltUI];
29+
} else if (authRecipe === "emailpassword") {
30+
recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
31+
} else if (authRecipe === "both") {
32+
recipePreBuiltUIList = [EmailPasswordPreBuiltUI, ThirdPartyPreBuiltUI];
33+
} else if (authRecipe === "thirdpartyemailpassword") {
34+
recipePreBuiltUIList = [ThirdPartyEmailPasswordPreBuiltUI];
35+
} else if (authRecipe === "passwordless") {
36+
recipePreBuiltUIList = [PasswordlessPreBuiltUI];
37+
} else if (authRecipe === "thirdpartypasswordless") {
38+
recipePreBuiltUIList = [ThirdPartyPasswordlessPreBuiltUI];
39+
}
40+
41+
if (emailVerificationMode !== "OFF") {
42+
recipePreBuiltUIList.push(EmailVerificationPreBuiltUI);
43+
}
44+
45+
const [, setCurrentPath] = useState(window.location.pathname);
46+
4847
useEffect(() => {
4948
const onLocationChange = () => {
5049
setCurrentPath(window.location.pathname);

examples/for-tests/src/AppWithoutRouter.js

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -18,29 +18,30 @@ function AppWithoutRouter() {
1818
</div>
1919
);
2020
}
21-
const authRecipe = window.localStorage.getItem("authRecipe") || "emailpassword";
22-
const emailVerificationMode = window.localStorage.getItem("mode") || "OFF";
2321

24-
let recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
25-
if (authRecipe === "thirdparty") {
26-
recipePreBuiltUIList = [ThirdPartyPreBuiltUI];
27-
} else if (authRecipe === "emailpassword") {
28-
recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
29-
} else if (authRecipe === "both") {
30-
recipePreBuiltUIList = [ThirdPartyPreBuiltUI, EmailPasswordPreBuiltUI];
31-
} else if (authRecipe === "thirdpartyemailpassword") {
32-
recipePreBuiltUIList = [ThirdPartyEmailPasswordPreBuiltUI];
33-
} else if (authRecipe === "passwordless") {
34-
recipePreBuiltUIList = [PasswordlessPreBuiltUI];
35-
} else if (authRecipe === "thirdpartypasswordless") {
36-
recipePreBuiltUIList = [ThirdPartyPasswordlessPreBuiltUI];
37-
}
22+
function Routing() {
23+
const authRecipe = window.localStorage.getItem("authRecipe") || "emailpassword";
24+
const emailVerificationMode = window.localStorage.getItem("mode") || "OFF";
3825

39-
if (emailVerificationMode !== "OFF") {
40-
recipePreBuiltUIList.push(EmailVerificationPreBuiltUI);
41-
}
26+
let recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
27+
if (authRecipe === "thirdparty") {
28+
recipePreBuiltUIList = [ThirdPartyPreBuiltUI];
29+
} else if (authRecipe === "emailpassword") {
30+
recipePreBuiltUIList = [EmailPasswordPreBuiltUI];
31+
} else if (authRecipe === "both") {
32+
recipePreBuiltUIList = [EmailPasswordPreBuiltUI, ThirdPartyPreBuiltUI];
33+
} else if (authRecipe === "thirdpartyemailpassword") {
34+
recipePreBuiltUIList = [ThirdPartyEmailPasswordPreBuiltUI];
35+
} else if (authRecipe === "passwordless") {
36+
recipePreBuiltUIList = [PasswordlessPreBuiltUI];
37+
} else if (authRecipe === "thirdpartypasswordless") {
38+
recipePreBuiltUIList = [ThirdPartyPasswordlessPreBuiltUI];
39+
}
40+
41+
if (emailVerificationMode !== "OFF") {
42+
recipePreBuiltUIList.push(EmailVerificationPreBuiltUI);
43+
}
4244

43-
function Routing() {
4445
const [, setCurrentPath] = useState(window.location.pathname);
4546

4647
useEffect(() => {

0 commit comments

Comments
 (0)