Skip to content
This repository was archived by the owner on Mar 10, 2020. It is now read-only.

Commit aeb0325

Browse files
Auto generate API.md using mocha
1 parent 31ddc9a commit aeb0325

File tree

3 files changed

+99
-2
lines changed

3 files changed

+99
-2
lines changed

API.md

+88
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# TOC
2+
- [IPFS Node.js API wrapper tests](#ipfs-nodejs-api-wrapper-tests)
3+
- [.send](#ipfs-nodejs-api-wrapper-tests-send)
4+
- [.add](#ipfs-nodejs-api-wrapper-tests-add)
5+
- [.cat](#ipfs-nodejs-api-wrapper-tests-cat)
6+
- [.ls](#ipfs-nodejs-api-wrapper-tests-ls)
7+
- [.config](#ipfs-nodejs-api-wrapper-tests-config)
8+
- [.update (currently disabled, wait for IPFS 0.4.0 release](#ipfs-nodejs-api-wrapper-tests-update-currently-disabled-wait-for-ipfs-040-release)
9+
- [.version](#ipfs-nodejs-api-wrapper-tests-version)
10+
- [.commands](#ipfs-nodejs-api-wrapper-tests-commands)
11+
- [.mount](#ipfs-nodejs-api-wrapper-tests-mount)
12+
- [.diag](#ipfs-nodejs-api-wrapper-tests-diag)
13+
- [.block](#ipfs-nodejs-api-wrapper-tests-block)
14+
- [.object](#ipfs-nodejs-api-wrapper-tests-object)
15+
- [.swarm](#ipfs-nodejs-api-wrapper-tests-swarm)
16+
- [.ping](#ipfs-nodejs-api-wrapper-tests-ping)
17+
- [.id](#ipfs-nodejs-api-wrapper-tests-id)
18+
- [.pin](#ipfs-nodejs-api-wrapper-tests-pin)
19+
- [.log](#ipfs-nodejs-api-wrapper-tests-log)
20+
- [.name](#ipfs-nodejs-api-wrapper-tests-name)
21+
- [.refs](#ipfs-nodejs-api-wrapper-tests-refs)
22+
- [.dht](#ipfs-nodejs-api-wrapper-tests-dht)
23+
<a name=""></a>
24+
25+
<a name="ipfs-nodejs-api-wrapper-tests"></a>
26+
# IPFS Node.js API wrapper tests
27+
has the api object.
28+
29+
```js
30+
assert(apiClients['a'])
31+
assert(apiClients['a'].id)
32+
```
33+
34+
<a name="ipfs-nodejs-api-wrapper-tests-send"></a>
35+
## .send
36+
<a name="ipfs-nodejs-api-wrapper-tests-add"></a>
37+
## .add
38+
<a name="ipfs-nodejs-api-wrapper-tests-cat"></a>
39+
## .cat
40+
<a name="ipfs-nodejs-api-wrapper-tests-ls"></a>
41+
## .ls
42+
<a name="ipfs-nodejs-api-wrapper-tests-config"></a>
43+
## .config
44+
<a name="ipfs-nodejs-api-wrapper-tests-update-currently-disabled-wait-for-ipfs-040-release"></a>
45+
## .update (currently disabled, wait for IPFS 0.4.0 release
46+
<a name="ipfs-nodejs-api-wrapper-tests-version"></a>
47+
## .version
48+
<a name="ipfs-nodejs-api-wrapper-tests-commands"></a>
49+
## .commands
50+
<a name="ipfs-nodejs-api-wrapper-tests-diag"></a>
51+
## .diag
52+
<a name="ipfs-nodejs-api-wrapper-tests-block"></a>
53+
## .block
54+
<a name="ipfs-nodejs-api-wrapper-tests-object"></a>
55+
## .object
56+
<a name="ipfs-nodejs-api-wrapper-tests-swarm"></a>
57+
## .swarm
58+
.swarm.connect.
59+
60+
```js
61+
// Done in the 'before' segment
62+
done()
63+
```
64+
65+
<a name="ipfs-nodejs-api-wrapper-tests-ping"></a>
66+
## .ping
67+
<a name="ipfs-nodejs-api-wrapper-tests-id"></a>
68+
## .id
69+
<a name="ipfs-nodejs-api-wrapper-tests-pin"></a>
70+
## .pin
71+
<a name="ipfs-nodejs-api-wrapper-tests-log"></a>
72+
## .log
73+
<a name="ipfs-nodejs-api-wrapper-tests-name"></a>
74+
## .name
75+
<a name="ipfs-nodejs-api-wrapper-tests-refs"></a>
76+
## .refs
77+
<a name="ipfs-nodejs-api-wrapper-tests-dht"></a>
78+
## .dht
79+
returns an error when getting a non-existent key from the DHT.
80+
81+
```js
82+
this.timeout(20000)
83+
apiClients['a'].dht.get('non-existent', {timeout: '100ms'}, function (err, value) {
84+
assert(err)
85+
done()
86+
})
87+
```
88+

package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
"gulp": "^3.9.0",
3737
"gulp-eslint": "^1.0.0",
3838
"gulp-load-plugins": "^1.0.0",
39-
"gulp-mocha": "^2.1.3",
39+
"gulp-spawn-mocha": "^2.2.1",
4040
"ipfsd-ctl": "^0.6.1",
4141
"karma": "^0.13.11",
4242
"karma-browserify": "^4.4.0",

tasks/test.js

+10-1
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,16 @@ gulp.task('test:browser', function (done) {
3333

3434
gulp.task('mocha', function () {
3535
return gulp.src('test/tests.js')
36-
.pipe($.mocha())
36+
.pipe($.spawnMocha())
37+
})
38+
39+
gulp.task('docs', function () {
40+
return gulp.src('test/tests.js')
41+
.pipe($.spawnMocha({
42+
reporter: 'markdown',
43+
output: 'API.md'
44+
}))
45+
3746
})
3847

3948
gulp.task('karma', function (done) {

0 commit comments

Comments
 (0)