Skip to content

Commit bb2733d

Browse files
committed
added complete unit tests
1 parent 65a6b0c commit bb2733d

File tree

10 files changed

+1386
-24
lines changed

10 files changed

+1386
-24
lines changed

package-lock.json

Lines changed: 1067 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"description": "JavaScript library for the Agility Fetch API (node and browser)",
55
"main": "dist/agility-content-fetch.node.js",
66
"scripts": {
7-
"test": "mocha --require @babel/register --recursive ./test",
7+
"test": "nyc --reporter=html --reporter=text mocha --require @babel/register --recursive ./test",
88
"generate-docs": "node_modules/.bin/jsdoc --configure .jsdoc.json --verbose",
99
"build": "webpack --config webpack.config -p"
1010
},
@@ -29,6 +29,7 @@
2929
"chai": "^4.2.0",
3030
"jsdoc": "^3.5.5",
3131
"mocha": "^6.0.2",
32+
"nyc": "^13.3.0",
3233
"webpack": "^4.29.6",
3334
"webpack-cli": "^3.2.3"
3435
},

src/api-client.js

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ const defaultConfig = {
1212
instanceID: null,
1313
accessToken: null,
1414
languageCode: null
15-
}
16-
15+
};
1716

1817
export default function createClient(userConfig) {
1918

@@ -24,6 +23,7 @@ export default function createClient(userConfig) {
2423
};
2524

2625
function makeRequest(reqConfig) {
26+
2727
return axios(reqConfig).then(response => {
2828
return response.data;
2929
});
@@ -39,6 +39,4 @@ export default function createClient(userConfig) {
3939
getPage: getPage
4040
}
4141

42-
}
43-
44-
42+
}

src/content-fetch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -49,13 +49,13 @@ function validateConfigParams(configParams) {
4949
if(!configParams.instanceID || configParams.instanceID.length == 0) {
5050
throw new TypeError('You must provide an instanceID');
5151
}
52-
53-
if(!configParams.accessToken || configParams.accessToken.length == 0) {
52+
else if(!configParams.accessToken || configParams.accessToken.length == 0) {
5453
throw new TypeError('You must provide an access token');
5554
}
56-
57-
if(!configParams.languageCode || configParams.languageCode.length == 0) {
55+
else if(!configParams.languageCode || configParams.languageCode.length == 0) {
5856
throw new TypeError('You must provide a language code');
57+
} else {
58+
return;
5959
}
6060
}
6161

src/methods/getContentItem.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function getContentItem(requestParams) {
4646
function validateRequestParams(requestParams) {
4747
if(!requestParams.contentID) {
4848
throw new TypeError('You must include a contentID number in your request params.');
49+
} else {
50+
return;
4951
}
5052
}
5153

src/methods/getContentList.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function getContentList(requestParams) {
4646
function validateRequestParams(requestParams) {
4747
if(!requestParams.referenceName) {
4848
throw new TypeError('You must include a content referenceName in your request params.');
49+
} else {
50+
return;
4951
}
5052
}
5153

src/methods/getPage.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function getPage(requestParams) {
4646
function validateRequestParams(requestParams) {
4747
if(!requestParams.pageID) {
4848
throw new TypeError('You must include a pageID in your request params.');
49+
} else {
50+
return;
4951
}
5052
}
5153

src/methods/getSitemapFlat.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,8 @@ function getSitemapFlat(requestParams) {
4646
function validateRequestParams(requestParams) {
4747
if(!requestParams.channelID) {
4848
throw new TypeError('You must include a channelID in your request params.');
49+
} else {
50+
return;
4951
}
5052
}
5153

src/methods/getSitemapNested.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ function getSitemapNested(requestParams) {
3232
validateRequestParams(requestParams);
3333

3434
const req = {
35-
url: `/Sitemap/Nested/${requestParams.channelID}`,
35+
//HACK
36+
//url: `/Sitemap/Nested/${requestParams.channelID}`,
37+
url: `/Sitemap/Nested`,
3638
method: 'get',
3739
baseURL: utils.buildRequestUrlPath(this.config),
3840
headers: utils.buildAuthHeader(this.config),

0 commit comments

Comments
 (0)