Skip to content

Commit 9cd9b11

Browse files
committed
Added tests.
1 parent 3ab734c commit 9cd9b11

File tree

15 files changed

+256
-7
lines changed

15 files changed

+256
-7
lines changed

.eslintrc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
"@neogeek/eslint-config-standards"
44
],
55
"rules": {
6-
"no-invalid-this": 0
6+
"no-invalid-this": 0,
7+
"sort-keys": 0
78
}
89
}

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
11
node_modules/
2+
3+
temp/

.npmignore

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
test/
2+
3+
temp/
4+
15
.eslintrc
26

7+
.travis.yml
8+
9+
Gruntfile.js
10+
311
Makefile

.travis.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
language: node_js
2+
node_js:
3+
- "4"
4+
- "5"
5+
- "6"
6+
- "7"
7+
before_install:
8+
- if [[ `npm -v` != 3* ]]; then npm i -g npm@3; fi
9+
sudo: false

Gruntfile.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
module.exports = grunt => {
2+
3+
grunt.loadNpmTasks('grunt-mkdir');
4+
grunt.loadNpmTasks('grunt-mocha-test');
5+
6+
grunt.loadTasks('tasks');
7+
8+
grunt.initConfig({
9+
'doxdox': {
10+
'custom template': {
11+
'inputs': ['test/fixtures/plugin.js'],
12+
'output': 'temp/plugin.md',
13+
'config': {
14+
'title': 'Sample Title',
15+
'description': 'Lorem ipsum dolor sit amet, consectetur adipisicing elit',
16+
'layout': 'test/fixtures/template.hbs',
17+
'packageFile': 'test/fixtures/package.json'
18+
}
19+
}
20+
},
21+
'mkdir': {
22+
'all': {
23+
'options': {
24+
'create': ['temp']
25+
}
26+
}
27+
},
28+
'mochaTest': {
29+
'doxdox': {
30+
'src': ['test/specs/**/*.js']
31+
}
32+
}
33+
});
34+
35+
grunt.registerTask('test', ['mkdir', 'doxdox', 'mochaTest']);
36+
37+
};

Makefile

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,14 @@ BIN=node_modules/.bin
22

33
test:
44
make lint
5+
$(BIN)/grunt test
6+
@make clean
57

68
lint:
79
$(BIN)/eslint tasks/doxdox.js
10+
$(BIN)/eslint test/specs/
11+
12+
clean:
13+
@rm -rf temp/ || exit 0;
14+
15+
.PHONY: test

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ module.exports = function (grunt) {
4848
'config': {
4949
'title': 'Sample Title',
5050
'description': 'Lorem ipsum dolor sit amet, consectetur adipisicing elit',
51-
'layout': 'docs/template.hbs'
51+
'layout': 'docs/template.hbs',
52+
'packageFile': 'package.json'
5253
}
5354
}
5455
}

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,14 @@
1111
},
1212
"devDependencies": {
1313
"@neogeek/eslint-config-standards": "1.10.0",
14-
"eslint": "3.12.2"
14+
"eslint": "3.12.2",
15+
"grunt": "1.0.1",
16+
"grunt-mkdir": "1.0.0",
17+
"grunt-mocha-test": "0.13.2",
18+
"mocha": "3.2.0"
1519
},
1620
"scripts": {
17-
"test": "make lint"
21+
"test": "make test"
1822
},
1923
"keywords": [
2024
"gruntplugin",

tasks/doxdox.js

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,17 @@
11
const doxdox = require('doxdox');
2+
const utils = require('doxdox/lib/utils');
23

34
module.exports = grunt => {
45

56
grunt.registerMultiTask('doxdox', 'Generate documentation with doxdox.', function plugin () {
67

78
const done = this.async();
89

9-
const pkg = grunt.file.readJSON('package.json');
10-
1110
const {inputs, output} = this.data;
1211

13-
const {description, ignore, layout, parser, title} = this.data.config || {};
12+
const {description, ignore, layout, packageFile, parser, title} = this.data.config || {};
13+
14+
const pkg = grunt.file.readJSON(utils.findPackageFileInPath(packageFile || 'package.json'));
1415

1516
doxdox.parseInputs(inputs, {
1617
'description': description || pkg.description || '',

test/.eslintrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"extends": [
3+
"@neogeek/eslint-config-standards/.eslintrc-tests"
4+
],
5+
"rules": {
6+
"no-sync": 0
7+
}
8+
}

0 commit comments

Comments
 (0)