-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathimage.js
More file actions
90 lines (76 loc) · 2.29 KB
/
image.js
File metadata and controls
90 lines (76 loc) · 2.29 KB
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
const { expect } = require('chai');
const uuidv4 = require('uuid/v4');
const sstk = require('../../src');
sstk.setAccessToken(process.env.SHUTTERSTOCK_API_TOKEN);
const imagesApi = new sstk.ImagesApi();
describe('images api', () => {
it('should be able to search', () => {
const params = {
query: "New York",
sort: "popular",
orientation: "horizontal",
};
return imagesApi.searchImages(params)
.then(function(res) {
expect(res).to.have.keys(
'data',
'search_id',
'total_count',
'page',
'per_page',
'spellcheck_info',
);
expect(res.data).to.be.an('array');
expect(res.data).to.not.be.empty;
});
});
it('should be able to see image details', () => {
const imageId = '1259378599';
const params = {
view: 'full',
};
return imagesApi.getImage(imageId, params)
.then(function(res) {
expect(res).to.have.keys(
'contributor',
'id',
'media_type',
'added_date',
'aspect',
'assets',
'categories',
'description',
'has_model_release',
'has_property_release',
'image_type',
'is_adult',
'is_editorial',
'is_illustration',
'keywords',
'model_releases',
'url',
);
expect(res.description).to.deep.equal('Happy New Year 2019. Chinese New Year. ' +
'The year of the pig. Translation: Greetings from the golden pig.');
});
});
it('should be able to rename my collection', () => {
const collectionId = '183608726';
const body = {
name: `Collection ${uuidv4()}`,
};
return imagesApi.renameImageCollection(collectionId, body)
.then(function(res) {
expect(res).to.be.null;
});
});
it('should be able to view my collection', () => {
const collectionId = '183608726';
const uuidv4Regex = '[0-9A-F]{8}-[0-9A-F]{4}-4[0-9A-F]{3}-[89AB][0-9A-F]{3}-[0-9A-F]{12}$';
return imagesApi.getImageCollection(collectionId, {})
.then(function(res) {
expect(res.id).to.equal('183608726');
expect(res.name).to.match(new RegExp(`^Collection ${uuidv4Regex}`, 'i'));
});
});
});