Skip to content

Commit

Permalink
test: backport test improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
porcellus committed Nov 27, 2024
1 parent 2182adb commit 17d3765
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 33 deletions.
9 changes: 3 additions & 6 deletions test/test-server/src/accountlinking.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import AccountLinkingRecipe from "../../../lib/build/recipe/accountlinking/recip
import AccountLinking from "../../../recipe/accountlinking";
import * as supertokens from "../../../lib/build";
import { logger } from "./logger";
import { serializeUser } from "./utils";
import { serializeResponse } from "./utils";

const namespace = "com.supertokens:node-test-server:accountlinking";
const { logDebugMessage } = logger(namespace);
Expand All @@ -15,7 +15,7 @@ const router = Router()
logDebugMessage("AccountLinking:createPrimaryUser %j", req.body);
const recipeUserId = supertokens.convertToRecipeUserId(req.body.recipeUserId);
const response = await AccountLinking.createPrimaryUser(recipeUserId, req.body.userContext);
res.json({ ...response, ...serializeUser(response) });
await serializeResponse(req, res, response);
} catch (e) {
next(e);
}
Expand All @@ -29,10 +29,7 @@ const router = Router()
req.body.primaryUserId,
req.body.userContext
);
res.json({
...response,
...serializeUser(response),
});
await serializeResponse(req, res, response);
} catch (e) {
next(e);
}
Expand Down
14 changes: 3 additions & 11 deletions test/test-server/src/emailpassword.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Router } from "express";
import EmailPassword from "../../../recipe/emailpassword";
import { convertRequestSessionToSessionObject, serializeRecipeUserId, serializeUser } from "./utils";
import { convertRequestSessionToSessionObject, serializeResponse } from "./utils";
import * as supertokens from "../../../lib/build";
import { logger } from "./logger";

Expand All @@ -19,11 +19,7 @@ const router = Router()
session,
req.body.userContext
);
res.json({
...response,
...serializeUser(response),
...serializeRecipeUserId(response),
});
await serializeResponse(req, res, response);
} catch (e) {
next(e);
}
Expand All @@ -39,11 +35,7 @@ const router = Router()
session,
req.body.userContext
);
res.json({
...response,
...serializeUser(response),
...serializeRecipeUserId(response),
});
await serializeResponse(req, res, response);
} catch (e) {
next(e);
}
Expand Down
23 changes: 7 additions & 16 deletions test/test-server/src/passwordless.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Router } from "express";
import SuperTokens from "../../..";
import Passwordless from "../../../recipe/passwordless";
import { convertRequestSessionToSessionObject, serializeRecipeUserId, serializeUser } from "./utils";
import { convertRequestSessionToSessionObject, serializeResponse } from "./utils";
import { logger } from "./logger";

const namespace = "com.supertokens:node-test-server:passwordless";
Expand All @@ -23,11 +23,8 @@ const router = Router()
session: req.body.session && (await convertRequestSessionToSessionObject(req.body.session)),
userContext: req.body.userContext,
});
res.json({
...response,
...serializeUser(response),
...serializeRecipeUserId(response),
});

await serializeResponse(req, res, response);
} catch (e) {
next(e);
}
Expand Down Expand Up @@ -60,11 +57,8 @@ const router = Router()
session: req.body.session && (await convertRequestSessionToSessionObject(req.body.session)),
userContext: req.body.userContext,
});
res.json({
...response,
...serializeUser(response),
...serializeRecipeUserId(response),
});

await serializeResponse(req, res, response);
} catch (e) {
next(e);
}
Expand All @@ -78,11 +72,8 @@ const router = Router()
phoneNumber: req.body.phoneNumber,
userContext: req.body.userContext,
});
res.json({
...response,
...serializeUser(response),
...serializeRecipeUserId(response),
});

await serializeResponse(req, res, response);
} catch (e) {
next(e);
}
Expand Down

0 comments on commit 17d3765

Please sign in to comment.