-
Notifications
You must be signed in to change notification settings - Fork 17
/
searchvideoscreativetests.js
183 lines (163 loc) · 9.47 KB
/
searchvideoscreativetests.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
const api = require("../gettyimages-api");
const nock = require("nock");
const test = require("ava");
test.beforeEach(() => {
nock("https://authentication.gettyimages.com")
.post("/oauth2/token", "client_id=apikey&client_secret=apisecret&grant_type=client_credentials")
.reply(200, {
access_token: "client_credentials_access_token",
token_type: "Bearer",
expires_in: "1800"
});
nock("https://api.gettyimages.com")
.get("/v3/search/videos/creative")
.query({ "phrase": "cat" })
.reply(200, {response : "phrase"})
.get("/v3/search/videos/creative")
.query({ "age_of_people": ["adult", "newborn", "0-1_months", "12-17_months", "mature_adult"].join(","), "phrase": "cat" })
.reply(200, {response : "age_of_people"})
.get("/v3/search/videos/creative")
.query({ "collection_codes": ["WRI", "ARF"].join(","), "phrase": "cat" })
.reply(200, {response : "collection_codes"})
.get("/v3/search/videos/creative")
.query({ "collections_filter_type": "exclude", "phrase": "cat" })
.reply(200, {response : "collections_filter_type"})
.get("/v3/search/videos/creative")
.query({ "exclude_editorial_use_only": "true", "phrase": "cat" })
.reply(200, {response : "exclude_editorial_use_only"})
.get("/v3/search/videos/creative")
.query({ "exclude_nudity": "true", "phrase": "cat" })
.reply(200, {response : "exclude_nudity"})
.get("/v3/search/videos/creative")
.query({ "fields": ["asset_family", "id"].join(","), "phrase": "cat" })
.reply(200, {response : "fields"})
.get("/v3/search/videos/creative")
.query({ "format_available": "hd", "phrase": "cat" })
.reply(200, {response : "format_available"})
.get("/v3/search/videos/creative")
.query({ "frame_rates": ["24", "29.97"].join(","), "phrase": "cat" })
.reply(200, {response : "frame_rates"})
.get("/v3/search/videos/creative")
.query({ "keyword_ids": [1234, 5678].join(","), "phrase": "cat" })
.reply(200, {response : "keyword_ids"})
.get("/v3/search/videos/creative")
.query({ "license_models": ["rightsmanaged", "royaltyfree"].join(","), "phrase": "cat" })
.reply(200, {response : "license_models"})
.get("/v3/search/videos/creative")
.query({ "page": 3, "phrase": "cat" })
.reply(200, {response : "page"})
.get("/v3/search/videos/creative")
.query({ "page_size": 50, "phrase": "cat" })
.reply(200, {response : "page_size"})
.get("/v3/search/videos/creative")
.query({ "product_types": ["easyaccess", "editorialsubscription"].join(","), "phrase": "cat" })
.reply(200, {response : "product_types"})
.get("/v3/search/videos/creative")
.query({ "safe_search": "true", "phrase": "cat" })
.reply(200, {response : "safe_search"})
.get("/v3/search/videos/creative")
.query({ "sort_order": "newest", "phrase": "cat" })
.reply(200, {response : "sort_order"})
.get("/v3/search/videos/creative")
.query({"phrase":"monkey"})
.reply(200,function(path, reqBody, cb) {
cb(null,[200, {response: "accept-language", headers: this.req.headers}]);
})
.get("/v3/search/videos/creative")
.query({ "min_clip_length": "15", "phrase": "cat" })
.reply(200, {response : "min_clip_length"});
});
test("SearchVideosCreative: withPhrase will include phrase in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").execute();
t.is(res.response, "phrase");
});
test("SearchVideosCreative: withAgeOfPeople will include age_of_people in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withAgeOfPeople(["adult", "newborn", "0-1_months"]).withAgeOfPeople(["12-17_months", "mature_adult"]).execute();
t.is(res.response, "age_of_people");
});
test("SearchVideosCreative: withCollectionCode will include collection_codes in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withCollectionCode(["WRI", "ARF"]).execute();
t.is(res.response, "collection_codes");
});
test("SearchVideosCreative: withCollectionsFilterType will include collections_filter_type in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withCollectionsFilterType("exclude").execute();
t.is(res.response, "collections_filter_type");
});
test("SearchVideosCreative: withExcludeEditorialUseOnly will include exclude_editorial_use_only in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withExcludeEditorialUseOnly(true).execute();
t.is(res.response, "exclude_editorial_use_only");
});
test("SearchVideosCreative: withExcludeNudity will include exclude_nudity in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withExcludeNudity(true).execute();
t.is(res.response, "exclude_nudity");
});
test("SearchVideosCreative: withResponseField will include fields in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withResponseField(["asset_family", "id"]).execute();
t.is(res.response, "fields");
});
test("SearchVideosCreative: withFormatAvailable will include format_available in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withFormatAvailable("hd").execute();
t.is(res.response, "format_available");
});
test("SearchVideosCreative: withFrameRate will include frame_rates in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withFrameRate(["24", "29.97"]).execute();
t.is(res.response, "frame_rates");
});
test("SearchVideosCreative: withKeywordId will include keyword_ids in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withKeywordId([1234, 5678]).execute();
t.is(res.response, "keyword_ids");
});
test("SearchVideosCreative: withLicenseModel will include license_models in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withLicenseModel(["rightsmanaged", "royaltyfree"]).execute();
t.is(res.response, "license_models");
});
test("SearchVideosCreative: withPage will include page in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withPage(3).execute();
t.is(res.response, "page");
});
test("SearchVideosCreative: withPageSize will include page_size in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withPageSize(50).execute();
t.is(res.response, "page_size");
});
test("SearchVideosCreative: withProductType will include product_types in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withProductType(["easyaccess", "editorialsubscription"]).execute();
t.is(res.response, "product_types");
});
test("SearchVideosCreative: withSafeSearch will include safe_search in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withSafeSearch(true).execute();
t.is(res.response, "safe_search");
});
test("SearchVideosCreative: withSortOrder will include sort_order in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withPhrase("cat").withSortOrder("newest").execute();
t.is(res.response, "sort_order");
});
test ("SearchVideosCreative: withAcceptLanguage will include the Accept-Language header in request", async t => {
var client = new api({apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withAcceptLanguage("en-us").withPhrase("monkey").execute();
var code = res[0];
var body = res[1];
t.is(code, 200);
t.is(body.headers["accept-language"], "en-us");
t.is(body.response, "accept-language");
});
test("SearchVideosCreative: withMinClipLength will include min_clip_length in query", async t => {
var client = new api({ apiKey: "apikey", apiSecret: "apisecret" }, null);
const res = await client.searchvideoscreative().withMinClipLength(15).withPhrase("cat").execute();
t.is(res.response, "min_clip_length");
});