Skip to content

Commit

Permalink
feat(templates): Now test templates include a root-level describe() f…
Browse files Browse the repository at this point in the history
…unction to wrap tests.
  • Loading branch information
Antonio Pintus committed May 3, 2017
1 parent 61c14f5 commit f81631c
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 18 deletions.
12 changes: 6 additions & 6 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,20 +43,20 @@
},
"homepage": "https://github.com/vivocha/api-piki",
"devDependencies": {
"chai": "^3.5.0",
"chai": "^3.5.0",
"commitizen": "2.9.6",
"coveralls": "^2.12.0",
"coveralls": "^2.13.1",
"cz-conventional-changelog": "2.0.0",
"husky": "^0.13.2",
"mocha": "^3.2.0",
"nyc": "^10.1.2",
"husky": "^0.13.3",
"mocha": "^3.3.0",
"nyc": "^10.3.0",
"rewire": "^2.5.2",
"semantic-release": "^6.3.2",
"supertest": "^3.0.0"
},
"dependencies": {
"commander": "^2.9.0",
"debug": "^2.6.3",
"debug": "^2.6.6",
"lodash": "^4.17.4",
"request": "^2.81.0"
},
Expand Down
11 changes: 6 additions & 5 deletions src/lib/common/templates/DeleteCollectionSkeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,14 @@ exports.getTest = ({baseURL, method = 'get', endpointPath, isAuthenticated=false
${skipComment}
${requirements(baseURL)}
${getBasicAuthCredentials()}
describe('DELETE ${endpointPath}', function() {
${isAuthenticated ? `${commonAuthTest(baseURL, method, endpointPath, username, userpasswd)}` : ''}
//the following test case is incomplete and can be used as a template to write new cases
describe.skip('${method.toUpperCase()} ${endpointPath}', function(){
it('TBD, write test case in the context of your DELETE ${endpointPath} semantics');
});
//the following test case is incomplete and can be used as a template to write new cases
describe.skip('${method.toUpperCase()} ${endpointPath}', function(){
it('TBD, write test case in the context of your DELETE ${endpointPath} semantics');
});
`}; //end skeleton
})`}; //end skeleton
3 changes: 2 additions & 1 deletion src/lib/common/templates/DeleteOneSkeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports.getTest = ({baseURL, method = 'get', endpointPath, isAuthenticated=false
${skipComment}
${requirements(baseURL)}
${getBasicAuthCredentials()}
describe('DELETE ${endpointPath}', function() {
${isAuthenticated ? `${commonAuthTest(baseURL, method, endpointPath.replace(/{.+}/, 'aSuperFakeID', username, userpasswd ))}` : ''}
Expand All @@ -27,4 +28,4 @@ describe.skip('${method.toUpperCase()} ${endpointPath}', function(){
${deleteTest( baseURL, endpointPath, "validResourceBody", isAuthenticated, username, userpasswd )}
});
`}; //end skeleton
});`}; //end skeleton
3 changes: 2 additions & 1 deletion src/lib/common/templates/GetCollectionSkeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ exports.getTest = ({baseURL, method = 'get', endpointPath, isAuthenticated=false
${skipComment}
${requirements(baseURL)}
${getBasicAuthCredentials()}
describe('GET ${endpointPath}', function() {
${notFoundForFakeTest(baseURL, isAuthenticated, username, userpasswd)}
${isAuthenticated ? `${commonAuthTest(baseURL, method, endpointPath, username, userpasswd )}` : ''}
${jsonListingTest(baseURL, endpointPath, isAuthenticated, username, userpasswd)}
Expand All @@ -37,4 +38,4 @@ describe.skip('${method.toUpperCase()} ${endpointPath}', function(){
});
});
});
`}; //end skeleton
});`}; //end skeleton
3 changes: 2 additions & 1 deletion src/lib/common/templates/GetOneSkeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ exports.getTest = ({baseURL, method = 'get', endpointPath, isAuthenticated=false
${skipComment}
${requirements(baseURL)}
${getBasicAuthCredentials()}
describe('GET ${endpointPath}', function() {
${isAuthenticated ? `${commonAuthTest(baseURL, method, endpointPath.replace(/{.+}/, 'aSuperFakeID'), username, userpasswd )}` : ''}
${testNotValidIdsTest(baseURL, method, endpointPath.replace(/{.+}/, ''), {}, isAuthenticated, username, userpasswd)}
Expand All @@ -39,4 +40,4 @@ describe.skip('${method.toUpperCase()} ${endpointPath} for an existing resource'
});
});
});
`}; //end skeleton
});`}; //end skeleton
3 changes: 2 additions & 1 deletion src/lib/common/templates/PostCollectionSkeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports.getTest = ({baseURL, method = 'get', endpointPath, isAuthenticated=false
${skipComment}
${requirements(baseURL)}
${getBasicAuthCredentials()}
describe('POST ${endpointPath}', function() {
${isAuthenticated ? `${commonAuthTest(baseURL, method, endpointPath, username, userpasswd )}` : ''}
describe.skip('POST Test Suite', function() {
Expand Down Expand Up @@ -79,4 +80,4 @@ describe.skip('POST Test Suite', function() {
});
`}; //end skeleton
});`}; //end skeleton
3 changes: 2 additions & 1 deletion src/lib/common/templates/PostOneSkeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ exports.getTest = ({baseURL, method = 'get', endpointPath, isAuthenticated=false
${skipComment}
${requirements(baseURL)}
${getBasicAuthCredentials()}
describe('POST ${endpointPath}', function() {
${isAuthenticated ? `${commonAuthTest(baseURL, method, endpointPath.replace(/{.+}/, 'aSuperFakeID', username, userpasswd ))}` : ''}
//the following test case is incomplete and can be used as a template to write new cases
Expand All @@ -21,4 +22,4 @@ describe.skip('${method.toUpperCase()} ${endpointPath}', function(){
`}; //end skeleton
});`}; //end skeleton
3 changes: 2 additions & 1 deletion src/lib/common/templates/PutCollectionSkeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,12 @@ exports.getTest = ({baseURL, method = 'get', endpointPath, isAuthenticated=false
${skipComment}
${requirements(baseURL)}
${getBasicAuthCredentials()}
describe('PUT ${endpointPath}', function() {
${isAuthenticated ? `${commonAuthTest(baseURL, method, endpointPath, username, userpasswd )}` : ''}
//the following test case is incomplete and can be used as a template to write new cases
describe.skip('${method.toUpperCase()} ${endpointPath}', function(){
it('TBD, write test case in the context of your PUT ${endpointPath} semantics');
});
`}; //end skeleton
});`}; //end skeleton
3 changes: 2 additions & 1 deletion src/lib/common/templates/PutOneSkeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ exports.getTest = ({baseURL, method = 'get', endpointPath, isAuthenticated=false
${skipComment}
${requirements(baseURL)}
${getBasicAuthCredentials()}
describe('DELETE ${endpointPath}', function() {
${isAuthenticated ? `${commonAuthTest(baseURL, method, endpointPath.replace(/{.+}/, 'aSuperFakeID', username, userpasswd ))}` : ''}
Expand Down Expand Up @@ -96,4 +97,4 @@ describe.skip('PUT Test Suite', function() {
});
`}; //end skeleton
});`}; //end skeleton

0 comments on commit f81631c

Please sign in to comment.