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

Commit c351f5e

Browse files
committed
docs: updates code examples
License: MIT Signed-off-by: Alan Shaw <[email protected]>
1 parent feb479b commit c351f5e

File tree

1 file changed

+50
-10
lines changed

1 file changed

+50
-10
lines changed

README.md

Lines changed: 50 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ Include this badge in your readme if you make a new module that implements inter
5252
## Install
5353

5454
In JavaScript land:
55+
5556
```js
5657
npm install interface-ipfs-core
5758
```
@@ -68,20 +69,59 @@ In Go land:
6869

6970
Install `interface-ipfs-core` as one of the dependencies of your project and as a test file. Then, using `mocha` (for Node.js) or a test runner with compatible API, do:
7071

71-
```
72-
var test = require('interface-ipfs-core')
73-
74-
var common = {
75-
setup: function (cb) {
76-
cb(null, IPFSFactory)
72+
```js
73+
const tests = require('interface-ipfs-core')
74+
75+
// Create common setup and teardown
76+
const createCommon = () => ({
77+
// Do some setup common to all tests
78+
setup (cb) {
79+
// Must call back with an "IPFS factory", an object with a `spawnNode` method
80+
cb(null, {
81+
// Use ipfsd-ctl or other to spawn an IPFS node for testing
82+
spawnNode (cb) { /* ... */ }
83+
})
7784
},
78-
teardown: function (cb) {
85+
// Dispose of nodes created by the IPFS factory and any other teardown
86+
teardown (cb) {
7987
cb()
8088
}
81-
}
89+
})
90+
91+
tests.block(createCommon)
92+
tests.config(createCommon)
93+
tests.dag(createCommon)
94+
// ...etc. (see js/src/index.js)
95+
```
96+
97+
#### Running tests by command
98+
99+
```js
100+
tests.repo.version(createCommon)
101+
```
102+
103+
#### Skipping tests
104+
105+
```js
106+
tests.repo.version(createCommon)
107+
tests.repo.stat(createCommon)
108+
tests.repo.gc(createCommon, { skip: true }) // pass an options object to skip these tests
109+
110+
// OR, at the subsystem level
111+
112+
tests.repo(createCommon, { skip: ['gc'] })
113+
```
114+
115+
#### Running only some tests
116+
117+
```js
118+
tests.repo.version(createCommon)
119+
tests.repo.stat(createCommon)
120+
tests.repo.gc(createCommon, { only: true }) // pass an options object to run only these tests
121+
122+
// OR, at the subsystem level
82123

83-
// use all of the test suits
84-
test.all(common)
124+
tests.repo(createCommon, { only: ['gc'] })
85125
```
86126

87127
### Go

0 commit comments

Comments
 (0)