Skip to content

Commit 9df4e0f

Browse files
committed
test: Add tests
1 parent 216c9db commit 9df4e0f

File tree

4 files changed

+82
-0
lines changed

4 files changed

+82
-0
lines changed

Gruntfile.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
'use strict';
2+
3+
module.exports = function(grunt) {
4+
grunt.initConfig({
5+
documentation: {
6+
default: {
7+
files: [
8+
{
9+
expand: true,
10+
cwd: 'tasks',
11+
src: ['**/*.js']
12+
}
13+
],
14+
options: {
15+
destination: 'test/tmp'
16+
}
17+
}
18+
},
19+
nodeunit: {
20+
tasks: ['test/test.js']
21+
},
22+
clean: {
23+
test: ['test/tmp/**']
24+
}
25+
});
26+
27+
grunt.loadTasks('tasks');
28+
grunt.loadNpmTasks('grunt-contrib-clean');
29+
grunt.loadNpmTasks('grunt-contrib-nodeunit');
30+
31+
grunt.registerTask('default', [
32+
'clean',
33+
'documentation',
34+
'nodeunit',
35+
'clean'
36+
]);
37+
};

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@
2626
"devDependencies": {
2727
"cz-conventional-changelog": "^2.0.0",
2828
"grunt": "latest",
29+
"grunt-contrib-clean": "^1.1.0",
30+
"grunt-contrib-nodeunit": "^1.0.0",
2931
"husky": "^0.13.3",
3032
"lint-staged": "^3.4.0",
3133
"prettier": "^1.2.2",

tasks/documentation.js

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,39 @@ var path = require('path'),
1111
documentation = require('documentation'),
1212
formats = require('documentation').formats;
1313

14+
/**
15+
* Grunt Documentation
16+
*
17+
* In your project's Gruntfile, add a section named `documentation` to the
18+
* data object passed into `grunt.initConfig()`.
19+
*
20+
* @param {Object} options
21+
* @param {string} options.destination
22+
* @param {string} [options.format=html] one of `'html'`, `'md'`, `'json'`
23+
* @param {string} options.filename custom filename for md or json
24+
* @param {Array<string>} [options.access=[protected,public,undefined] Include only
25+
* comments with a given access level, out of `private`, `protected`, `public`
26+
* and `undefined`. By default, `public`, `protected` and `undefined` access levels are included.
27+
* @param {Array<string>} [options.order=[]] Explicit sort order
28+
* @param {string} [options.theme=''] Custom theme
29+
* @param {string} [options.name=''] project name
30+
* @param {string} [options.version=''] project version
31+
* @example
32+
* grunt.initConfig({
33+
* documentation: {
34+
* default: {
35+
* files: [{
36+
* "expand": true,
37+
* "cwd": "src",
38+
* "src": ["**\/*.js"]
39+
* }],
40+
* options: {
41+
* destination: "docs"
42+
* }
43+
* },
44+
* }
45+
* });
46+
*/
1447
function gruntDocumentation(grunt) {
1548
grunt.registerMultiTask(
1649
'documentation',

test/test.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
'use strict';
2+
var fs = require('fs');
3+
4+
exports.documentationjs = {
5+
run: function(test) {
6+
var code = fs.readFileSync('test/tmp/index.html', 'utf8');
7+
test.ok(/gruntDocumentation/.test(code));
8+
test.done();
9+
}
10+
};

0 commit comments

Comments
 (0)