-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathcreateRequestBody.test.ts
28 lines (22 loc) · 986 Bytes
/
createRequestBody.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import { test, expect } from "vitest";
import { createRequestBody } from "../src/createRequestBody";
test("Should create request body for specific text input with default options", () => {
const result = createRequestBody("test");
expect(decodeURIComponent(result)).toBe('f.req=[[["MkEWBc","[[\\"test\\",\\"auto\\",\\"en\\",1],[]]",null,"generic"]]]&');
});
test("Should create request body for specific text input with custom options", () => {
const result = createRequestBody("test", {
rpcids: "TEST_rpc",
from: "de",
to: "gu",
});
expect(decodeURIComponent(result)).toBe('f.req=[[["TEST_rpc","[[\\"test\\",\\"de\\",\\"gu\\",1],[]]",null,"generic"]]]&');
});
test("Should escape quotes", () => {
const result = createRequestBody('test "test"', {
rpcids: "TEST_rpc",
from: "de",
to: "gu",
});
expect(decodeURIComponent(result)).toBe('f.req=[[["TEST_rpc","[[\\"test \\\\\\"test\\\\\\"\\",\\"de\\",\\"gu\\",1],[]]",null,"generic"]]]&');
});