Skip to content

Commit 28ae7e6

Browse files
committed
included test to test url
1 parent c9fb78b commit 28ae7e6

3 files changed

Lines changed: 27 additions & 3 deletions

File tree

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "ebay-node-api",
3-
"version": "1.0.0",
3+
"version": "1.0.1",
44
"description": "Ebay node api client",
55
"main": "./src/index.js",
66
"homepage": "https://github.com/ajay2507/ebay-node-api",

src/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@ Ebay.prototype = {
7474
},
7575

7676
getUserDetails: function (userID) {
77+
if (!userID) throw new Error("User ID is null or invalid");
7778
this.options.operationName = "GetUserProfile";
7879
this.options.param = "UserID";
7980
this.options.name = userID;

test/testBuildURL.js

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@ let buildURL = require('../src/buildURL');
55

66
describe("test building url methods", () => {
77

8-
let expected_search_url = "http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=testID&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD&keywords=iphone&paginationInput.entriesPerPage=6&GLOBAL-ID=EBAY-US"
9-
it("test search url", () => {
108

9+
it("test search url", () => {
10+
let expected_search_url = "http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=testID&OPERATION-NAME=findItemsByKeywords&SERVICE-VERSION=1.0.0&RESPONSE-DATA-FORMAT=JSON&REST-PAYLOAD&keywords=iphone&paginationInput.entriesPerPage=6&GLOBAL-ID=EBAY-US"
1111
let options = {
1212
name: "iphone",
1313
operationName: "findItemsByKeywords",
@@ -18,4 +18,27 @@ describe("test building url methods", () => {
1818
}
1919
expect(buildURL.buildSearchUrl(options)).to.be.equal(expected_search_url);
2020
});
21+
22+
it("test Shopping url without selector", () => {
23+
let expected_search_url = "http://open.api.ebay.com/Shopping?appid=testID&callname=demoShoppingName&version=967&siteid=0&responseencoding=JSON&keywords=iphone"
24+
let options = {
25+
name: "iphone",
26+
operationName: "demoShoppingName",
27+
param: "keywords",
28+
clientID: "testID",
29+
}
30+
expect(buildURL.buildShoppingUrl(options)).to.be.equal(expected_search_url);
31+
});
32+
33+
it("test Shopping url including selector", () => {
34+
let expected_search_url = "http://open.api.ebay.com/Shopping?appid=testID&callname=demoShoppingName&version=967&siteid=0&responseencoding=JSON&keywords=iphone&IncludeSelector=true"
35+
let options = {
36+
name: "iphone",
37+
operationName: "demoShoppingName",
38+
param: "keywords",
39+
clientID: "testID",
40+
includeSelector: true
41+
}
42+
expect(buildURL.buildShoppingUrl(options)).to.be.equal(expected_search_url);
43+
});
2144
});

0 commit comments

Comments
 (0)