diff --git a/README.md b/README.md index 2f9ee61c..7d2f15ff 100644 --- a/README.md +++ b/README.md @@ -9,6 +9,7 @@ ## Table of Contents +- [Table of Contents](#table-of-contents) - [Background](#background) - [Modules that implement the interface](#modules-that-implement-the-interface) - [Badge](#badge) @@ -76,22 +77,42 @@ In Go land: ### Node.js -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: +Install `interface-ipfs-core` as one of the dependencies of your project. Install the following test file: -``` -var test = require('interface-ipfs-core') +```js +/* eslint-env mocha */ +'use strict' + +const test = require('interface-ipfs-core') +const IPFS = require('ipfs') // This should be your own instance, not the package ipfs. -var common = { +const common = { setup: function (cb) { - cb(null, yourIPFSInstance) + const ipfs = new IPFS() + ipfs.load(() => { + cb(null, ipfs) + }) }, teardown: function (cb) { cb() } } -// use all of the test suits -test.all(common) +test.files(common) +``` + +Then, using `mocha` (for Node.js) or a test runner with compatible API, do: + +```sh +mocha test.js +``` + +To test this yourself, you can clone this repo and run a test on [test.js](examples/test.js): + +```sh +npm install +npm install -g mocha ipfs +mocha test.js ``` ### Go diff --git a/examples/test.js b/examples/test.js new file mode 100644 index 00000000..7df3d73f --- /dev/null +++ b/examples/test.js @@ -0,0 +1,19 @@ +/* eslint-env mocha */ +'use strict' + +const test = require('./src/index.js') // Replace with interface-ipfs-core in your repo +const IPFS = require('ipfs') + +const common = { + setup: function (cb) { + const ipfs = new IPFS() // Replace with your instance + ipfs.load(() => { + cb(null, ipfs) + }) + }, + teardown: function (cb) { + cb() + } +} + +test.files(common) \ No newline at end of file