generated from wrappid/wrappid-module
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
adding new function in refresh token file ref #67
- Loading branch information
1 parent
61e0f41
commit 04dcadb
Showing
1 changed file
with
4 additions
and
60 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,66 +1,10 @@ | ||
import { describe, test, expect } from "@jest/globals"; | ||
import { WrappaidTest, coreConstant } from "@wrappid/service-core"; | ||
import request from "supertest"; | ||
|
||
const API_URL = "https://demoapi.wrappid.dev/"; | ||
|
||
const APIReqMethod: {[key: string]: RequestMethod} = { | ||
GET: "get", | ||
POST: "post", | ||
PUT: "put", | ||
PATCH: "patch" | ||
}; | ||
|
||
type GenericObject ={ | ||
[key: string]: any | ||
} | ||
|
||
type RequestMethod = "get" | "post" | "put" | "patch"; | ||
|
||
type APITestOptionsType = { | ||
method: RequestMethod; | ||
endpoint: string; | ||
data?: GenericObject | ||
} | ||
|
||
async function apiTest(options: APITestOptionsType) { | ||
const apiRequest = request(API_URL); | ||
// .set("Content-Type", "application/json") | ||
// .set("Accept-Encoding", "gzip, deflate, br") | ||
// .set("Connection", "keep-alive") | ||
// .set("User-Agent", | ||
// "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"); | ||
|
||
let requestInstance = null; | ||
|
||
switch (options.method) { | ||
case APIReqMethod.GET: | ||
requestInstance = apiRequest.get(options.endpoint); | ||
|
||
break; | ||
case APIReqMethod.POST: | ||
requestInstance = apiRequest.post(options.endpoint); | ||
|
||
break; | ||
case APIReqMethod.PUT: | ||
requestInstance = apiRequest.put(options.endpoint); | ||
|
||
break; | ||
case APIReqMethod.PATCH: | ||
requestInstance = apiRequest.patch(options.endpoint); | ||
|
||
break; | ||
default: | ||
throw new Error("Method was not mentioned"); | ||
break; | ||
} | ||
|
||
return await requestInstance.send(options.data).set("Content-Type", "application/json") | ||
.set("Accept-Encoding", "gzip, deflate, br") | ||
.set("Connection", "keep-alive") | ||
.set("User-Agent", | ||
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/121.0.0.0 Safari/537.36"); | ||
|
||
} | ||
const wrappidTest = new WrappaidTest({baseURL: API_URL}); | ||
|
||
describe("login", () => { | ||
test("TC01 Verify API Response Status Code", async () => { | ||
|
@@ -78,8 +22,8 @@ describe("login", () => { | |
|
||
test("TC01 Verify API Response Status Code _ through function", async () => { | ||
//{ emailOrPhone: "[email protected]", password: "Pritam@rxefy123" } | ||
const response = await apiTest({ | ||
method: APIReqMethod.POST, | ||
const response = await wrappidTest.apiTest({ | ||
method: coreConstant.httpMethod.HTTP_POST, | ||
endpoint: "login", | ||
data: { emailOrPhone: "[email protected]", password: "Asdf123@@" } | ||
}); | ||
|