-
Notifications
You must be signed in to change notification settings - Fork 75
/
Copy pathfinding.test.js
43 lines (39 loc) · 1.88 KB
/
finding.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
'use strict';
const expect = require('chai').expect;
const nock = require('nock');
const Ebay = require('../src/index');
const nockFindingApi = nock('https://svcs.ebay.com/');
describe('test ebay finding Api', () => {
describe('test findingApi methods with required params', () => {
it('test findItemsByCategory with required params', () => {
const ebay = new Ebay({
clientID: 'ClientId'
});
expect(() => { ebay.findItemsByCategory(); }).to.throw('Category ID is null or invalid');
});
it('test findCompletedItemswith required params', () => {
const ebay = new Ebay({
clientID: 'ClientId'
});
expect(() => { ebay.findCompletedItems(''); }).to.throw('Keyword or category ID are required.');
});
});
describe('test all get apis', () => {
it('test findItemsAdvanced', () => {
const ebay = new Ebay({
clientID: 'ABCD'
});
nockFindingApi.get('/services/search/FindingService/v1?SECURITY-APPNAME=ABCD&OPERATION-NAME=findItemsAdvanced&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&paginationInput.entriesPerPage=2&keywords=ipad&itemFilter(0).name=ExpeditedShippingType&itemFilter(0).value=OneDayShipping&outputSelector(0)=SellerInfo&outputSelector(1)=PictureURLLarge&outputSelector(2)=PictureURLSuperSize&GLOBAL-ID=EBAY-US')
.reply(200, { 'findItemsAdvancedResponse': [{ 'ack': ['Success'] }] });
return ebay.findItemsAdvanced({
entriesPerPage: 2,
keywords: 'ipad',
ExpeditedShippingType: 'OneDayShipping'
}).then((data) => {
expect(data.findItemsAdvancedResponse).not.null;
}, (error) => {
console.log(error); // eslint-disable-line no-console
});
});
});
});