-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathserp_api.test.js
68 lines (65 loc) · 1.9 KB
/
serp_api.test.js
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
const serphouse = require("../lib/SERPHouse")(process.env.API_KEY);
var id_key = "";
describe("SerpApi.live()", () => {
test("Performing a realtime search ", async () => {
const payload = {
data: {
q: "Coffee",
domain: "google.com",
lang: "en",
device: "desktop",
serp_type: "web",
loc: "Alba,Texas,United States",
verbatim: 0,
postback_url:
"https://webhook.site/8f885f1f-c38a-4a10-8506-335441213208",
page: 1,
num_result: 10,
},
path: { responseType: "json" },
};
const response = await serphouse.SerpApi.live(payload);
id_key = response.results.search_metadata.id;
expect(response.status).toBe("success");
});
});
describe("SerpApi.schedule()", () => {
test("Create the new serp schedule ", async () => {
const payload = {
data: [
{
q: "Coffee",
domain: "google.com",
lang: "en",
device: "desktop",
serp_type: "web",
loc: "Alba,Texas,United States",
verbatim: 0,
postback_url:
"https://webhook.site/8f885f1f-c38a-4a10-8506-335441213208",
page: 1,
num_result: 10,
},
],
};
const response = await serphouse.SerpApi.schedule(payload);
expect(response.status).toBe("success");
});
});
describe("SerpApi.get()", () => {
test("You will receive result of serp query ", async () => {
const payload = {
query: { id: id_key },
path: { responseType: "json" },
};
const response = await serphouse.SerpApi.get(payload);
expect(response.status).toBe("success");
});
});
describe("SerpApi.check()", () => {
test("You will get a status of your task ", async () => {
const payload = { query: { id: id_key } };
const response = await serphouse.SerpApi.check(payload);
expect(response.status).toBe("success");
});
});