1+ 'use strict' ;
12const expect = require ( 'chai' ) . expect ;
23const should = require ( 'chai' ) . should ( ) ;
34const nock = require ( 'nock' ) ;
4- const eBay = require ( '../src/index' ) ;
5+ const Ebay = require ( '../src/index' ) ;
56const { constructAdditionalParams } = require ( '../src/findingApi' ) ;
67const nockFindingApi = nock ( 'https://svcs.ebay.com/' ) ;
78
89describe ( 'test ebay finding Api' , ( ) => {
910
1011 describe ( 'test findingApi methods with required params' , ( ) => {
1112 it ( 'test findItemsByCategory with required params' , ( ) => {
12- let ebay = new eBay ( {
13+ let ebay = new Ebay ( {
1314 clientID : 'ClientId'
1415 } ) ;
1516 expect ( ( ) => { ebay . findItemsByCategory ( ) ; } ) . to . throw ( 'Category ID is null or invalid' ) ;
1617 } ) ;
1718
1819 it ( 'test findCompletedItemswith required params' , ( ) => {
19- let ebay = new eBay ( {
20+ let ebay = new Ebay ( {
2021 clientID : 'ClientId'
2122 } ) ;
2223 expect ( ( ) => { ebay . findCompletedItems ( '' ) ; } ) . to . throw ( 'Keyword or category ID are required.' ) ;
@@ -25,20 +26,20 @@ describe('test ebay finding Api', () => {
2526
2627 describe ( 'test constructAdditionalParams' , ( ) => {
2728 it ( 'test constructAdditionalParams with required params' , ( ) => {
28- let expected_param = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest' ;
29+ let expectedParam = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest' ;
2930 const options = {
3031 keywords : 'iphone' ,
3132 categoryId : '111' ,
3233 sortOrder : 'PricePlusShippingLowest'
3334 } ;
3435 const emptyOptions = { } ;
35- expect ( constructAdditionalParams ( options ) ) . to . be . equal ( expected_param ) ;
36+ expect ( constructAdditionalParams ( options ) ) . to . be . equal ( expectedParam ) ;
3637 expect ( constructAdditionalParams ( emptyOptions ) ) . to . be . equal ( '' ) ;
3738 } ) ;
3839
3940 it ( 'test constructAdditionalParams with affiliate params' , ( ) => {
40- let expected_param_with_affiliate = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest&affiliate.trackingId=1234567899&affiliate.networkId=123' ;
41- let expected_param = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest' ;
41+ let expectedParamWithAffiliate = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest&affiliate.trackingId=1234567899&affiliate.networkId=123' ;
42+ let expectedParam = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest' ;
4243 const options = {
4344 keywords : 'iphone' ,
4445 categoryId : '111' ,
@@ -55,14 +56,14 @@ describe('test ebay finding Api', () => {
5556 sortOrder : 'PricePlusShippingLowest'
5657 } ;
5758 const emptyOptions = { } ;
58- expect ( constructAdditionalParams ( options ) ) . to . be . equal ( expected_param_with_affiliate ) ;
59- expect ( constructAdditionalParams ( optionsWithNoAffiliate ) ) . to . be . equal ( expected_param ) ;
59+ expect ( constructAdditionalParams ( options ) ) . to . be . equal ( expectedParamWithAffiliate ) ;
60+ expect ( constructAdditionalParams ( optionsWithNoAffiliate ) ) . to . be . equal ( expectedParam ) ;
6061 expect ( constructAdditionalParams ( emptyOptions ) ) . to . be . equal ( '' ) ;
6162 } ) ;
6263
6364 it ( 'test constructAdditionalParams with additional params' , ( ) => {
64- let expected_param = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest&itemFilter(0).name=Condition&itemFilter(0).value=3000&itemFilter(1).name=SoldItemsOnly&itemFilter(1).value=true' ;
65- let expected_pag_param = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest&itemFilter(0).name=Condition&itemFilter(0).value=3000&itemFilter(1).name=SoldItemsOnly&itemFilter(1).value=true&paginationInput.entriesPerPage=2' ;
65+ let expectedParam = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest&itemFilter(0).name=Condition&itemFilter(0).value=3000&itemFilter(1).name=SoldItemsOnly&itemFilter(1).value=true' ;
66+ let expectedPaginationParam = 'keywords=iphone&categoryId=111&sortOrder=PricePlusShippingLowest&itemFilter(0).name=Condition&itemFilter(0).value=3000&itemFilter(1).name=SoldItemsOnly&itemFilter(1).value=true&paginationInput.entriesPerPage=2' ;
6667 const options = {
6768 keywords : 'iphone' ,
6869 categoryId : '111' ,
@@ -78,18 +79,18 @@ describe('test ebay finding Api', () => {
7879 SoldItemsOnly : true ,
7980 entriesPerPage : 2
8081 } ;
81- expect ( constructAdditionalParams ( options ) ) . to . be . equal ( expected_param ) ;
82- expect ( constructAdditionalParams ( optionsWithPagination ) ) . to . be . equal ( expected_pag_param ) ;
82+ expect ( constructAdditionalParams ( options ) ) . to . be . equal ( expectedParam ) ;
83+ expect ( constructAdditionalParams ( optionsWithPagination ) ) . to . be . equal ( expectedPaginationParam ) ;
8384 } ) ;
8485 } ) ;
8586
8687 describe ( 'test all get apis' , ( ) => {
87- it ( " test findItemsAdvanced" , ( ) => {
88- let ebay = new eBay ( {
88+ it ( ' test findItemsAdvanced' , ( ) => {
89+ let ebay = new Ebay ( {
8990 clientID : 'ABCD'
9091 } ) ;
9192 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&GLOBAL-ID=EBAY-US' )
92- . reply ( 200 , { " findItemsAdvancedResponse" : [ { " ack" : [ " Success" ] } ] } ) ;
93+ . reply ( 200 , { ' findItemsAdvancedResponse' : [ { ' ack' : [ ' Success' ] } ] } ) ;
9394 return ebay . findItemsAdvanced ( {
9495 entriesPerPage : 2 ,
9596 keywords : 'ipad' ,
@@ -101,4 +102,4 @@ describe('test ebay finding Api', () => {
101102 } ) ;
102103 } ) ;
103104 } ) ;
104- } ) ;
105+ } ) ;
0 commit comments