1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 | var extractArgs = function(fn) {
|
18 | 'use strict';
|
19 |
|
20 | if (typeof fn !== 'function') {
|
21 | throw new Error('TypeError : The extractArgs function requires the fn argument to be a function!');
|
22 | }
|
23 | return fn.toString().match(/function\s+\w*\s*\((.*?)\)/)[1].split(/\s*,\s*/);
|
24 | };
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 | exports.JsdocTest = {
|
34 |
|
35 | |
36 |
|
37 |
|
38 |
|
39 |
|
40 | setUp: function(done) {
|
41 | 'use strict';
|
42 |
|
43 | this.jsdocTask = require('../tasks/jsdoc-plugin');
|
44 | done();
|
45 | },
|
46 |
|
47 | |
48 |
|
49 |
|
50 |
|
51 |
|
52 | 'taskCheck': function(test) {
|
53 | 'use strict';
|
54 |
|
55 | test.notStrictEqual(this.jsdocTask, undefined, 'the jsdoc task should be set up');
|
56 | test.equal(typeof this.jsdocTask, 'function', 'the task must be a function');
|
57 |
|
58 | var taskArgs = extractArgs(this.jsdocTask);
|
59 | test.ok(taskArgs.length > 0 && taskArgs[0] === 'grunt', 'the task must declare the grunt context as 1st parameter');
|
60 |
|
61 | test.done();
|
62 | },
|
63 |
|
64 | |
65 |
|
66 |
|
67 |
|
68 |
|
69 | 'execCheck': function(test) {
|
70 | 'use strict';
|
71 |
|
72 | var exec = require('../tasks/lib/exec');
|
73 |
|
74 | test.notStrictEqual(exec, undefined, 'the exec lib should be required');
|
75 | test.equal(typeof exec, 'object', 'exec is an object');
|
76 |
|
77 | test.equal(typeof exec.buildSpawned, 'function', 'exec must have a buildSpawned method');
|
78 | test.equal(typeof exec.lookup, 'function', 'exec must have a lookup method');
|
79 |
|
80 | test.done();
|
81 | }
|
82 | };
|
83 |
|