Skip to content

Commit

Permalink
removes try catch from tests for front-token - #11
Browse files Browse the repository at this point in the history
  • Loading branch information
rishabhpoddar committed Nov 6, 2020
1 parent f579c27 commit 6e1852c
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 42 deletions.
31 changes: 10 additions & 21 deletions test/axios.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -360,21 +360,15 @@ describe("Axios AuthHttpRequest class tests", function() {
});
assertEqual(userId, loginResponse.data);

try {
// TODO: remove try catch
let data = await supertokens.getJWTPayloadSecurely();
assertEqual(Object.keys(data).length, 0);
} catch (ignored) {}
let data = await supertokens.getJWTPayloadSecurely();
assertEqual(Object.keys(data).length, 0);

// update jwt data
let testResponse1 = await axios.post(`${BASE_URL}/update-jwt`, { key: "data" });
assertEqual(testResponse1.data.key, "data");

try {
// TODO: remove try catch
data = await supertokens.getJWTPayloadSecurely();
assertEqual(data.key, "data");
} catch (ignored) {}
data = await supertokens.getJWTPayloadSecurely();
assertEqual(data.key, "data");

// get jwt data
let testResponse2 = await axios.get(`${BASE_URL}/update-jwt`);
Expand All @@ -385,12 +379,9 @@ describe("Axios AuthHttpRequest class tests", function() {
assertEqual(testResponse3.data.key1, "data1");
assertEqual(testResponse3.data.key, undefined);

try {
// TODO: remove try catch
data = await supertokens.getJWTPayloadSecurely();
assertEqual(data.key1, "data1");
assertEqual(data.key, undefined);
} catch (ignored) {}
data = await supertokens.getJWTPayloadSecurely();
assertEqual(data.key1, "data1");
assertEqual(data.key, undefined);

// get jwt data
let testResponse4 = await axios.get(`${BASE_URL}/update-jwt`);
Expand Down Expand Up @@ -541,11 +532,9 @@ describe("Axios AuthHttpRequest class tests", function() {
assertEqual(userId, loginResponse.data);
assertEqual(await supertokens.doesSessionExist(), true);
assertEqual(getAntiCSRFromCookie() !== null, true);
try {
// TODO: remove this try catch after all drivers have implemented front-token
let userIdFromToken = supertokens.getUserId();
assertEqual(userIdFromToken, userId);
} catch (ignored) {}

let userIdFromToken = supertokens.getUserId();
assertEqual(userIdFromToken, userId);

// send api request to logout
let logoutResponse = await axios.post(`${BASE_URL}/logout`, JSON.stringify({ userId }), {
Expand Down
31 changes: 10 additions & 21 deletions test/fetch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -348,11 +348,8 @@ describe("Fetch AuthHttpRequest class tests", function() {

assertEqual(await loginResponse.text(), userId);

try {
// TODO: remove try catch
let data = await supertokens.getJWTPayloadSecurely();
assertEqual(Object.keys(data).length, 0);
} catch (ignored) {}
let data = await supertokens.getJWTPayloadSecurely();
assertEqual(Object.keys(data).length, 0);

// update jwt data
let testResponse1 = await fetch(`${BASE_URL}/update-jwt`, {
Expand All @@ -366,11 +363,8 @@ describe("Fetch AuthHttpRequest class tests", function() {
let data1 = await testResponse1.json();
assertEqual(data1.key, "data");

try {
// TODO: remove try catch
data = await supertokens.getJWTPayloadSecurely();
assertEqual(data.key, "data");
} catch (ignored) {}
data = await supertokens.getJWTPayloadSecurely();
assertEqual(data.key, "data");

// get jwt data
let testResponse2 = await fetch(`${BASE_URL}/update-jwt`, { method: "get" });
Expand All @@ -390,12 +384,9 @@ describe("Fetch AuthHttpRequest class tests", function() {
assertEqual(data3.key1, "data1");
assertEqual(data3.key, undefined);

try {
// TODO: remove try catch
data = await supertokens.getJWTPayloadSecurely();
assertEqual(data.key1, "data1");
assertEqual(data.key, undefined);
} catch (ignored) {}
data = await supertokens.getJWTPayloadSecurely();
assertEqual(data.key1, "data1");
assertEqual(data.key, undefined);

// get jwt data
let testResponse4 = await fetch(`${BASE_URL}/update-jwt`, { method: "get" });
Expand Down Expand Up @@ -558,11 +549,9 @@ describe("Fetch AuthHttpRequest class tests", function() {

assertEqual(await supertokens.doesSessionExist(), true);
assertEqual(getAntiCSRFromCookie() !== null, true);
try {
// TODO: remove this try catch after all drivers have implemented front-token
let userIdFromToken = supertokens.getUserId();
assertEqual(userIdFromToken, userId);
} catch (ignored) {}

let userIdFromToken = supertokens.getUserId();
assertEqual(userIdFromToken, userId);

// send api request to logout
let logoutResponse = await fetch(`${BASE_URL}/logout`, {
Expand Down

0 comments on commit 6e1852c

Please sign in to comment.