From 7d26ca60b4d3ca85da289dfc028a27cc0d03516b Mon Sep 17 00:00:00 2001 From: Henrique Dias Date: Tue, 9 Jan 2018 12:03:21 +0000 Subject: [PATCH] tests --- test/cli/commands.js | 2 +- test/cli/dns.js | 22 ++++++++++++++++++++++ test/http-api/extra/dns.js | 19 +++++++++++++++++++ test/http-api/spec/dns.js | 24 ++++++++++++++++++++++++ 4 files changed, 66 insertions(+), 1 deletion(-) create mode 100644 test/cli/dns.js create mode 100644 test/http-api/extra/dns.js create mode 100644 test/http-api/spec/dns.js diff --git a/test/cli/commands.js b/test/cli/commands.js index 558cbcc8b4..3a2d85a418 100644 --- a/test/cli/commands.js +++ b/test/cli/commands.js @@ -4,7 +4,7 @@ const expect = require('chai').expect const runOnAndOff = require('../utils/on-and-off') -const commandCount = 59 +const commandCount = 60 describe('commands', () => runOnAndOff((thing) => { let ipfs diff --git a/test/cli/dns.js b/test/cli/dns.js new file mode 100644 index 0000000000..2a90dae444 --- /dev/null +++ b/test/cli/dns.js @@ -0,0 +1,22 @@ +/* eslint-env mocha */ +'use strict' + +const expect = require('chai').expect +const runOnAndOff = require('../utils/on-and-off') + +describe('dns', () => runOnAndOff((thing) => { + let ipfs + + before(function () { + this.timeout(60 * 1000) + ipfs = thing.ipfs + }) + + it('dns record for ipfs.io', function () { + this.timeout(60 * 1000) + + return ipfs('ipfs.io').then((res) => { + expect(res.substr(0, 6)).to.eql('/ipfs/') + }) + }) +})) diff --git a/test/http-api/extra/dns.js b/test/http-api/extra/dns.js new file mode 100644 index 0000000000..2368378a87 --- /dev/null +++ b/test/http-api/extra/dns.js @@ -0,0 +1,19 @@ +/* eslint-env mocha */ +'use strict' + +const chai = require('chai') +const dirtyChai = require('dirty-chai') +const expect = chai.expect +chai.use(dirtyChai) + +module.exports = (ctl) => { + describe('.dns', () => { + it('get dns for ipfs.io', (done) => { + ctl.dns('ipfs.io', (err, result) => { + expect(err).to.not.exist() + expect(result).to.exist() + done() + }) + }) + }) +} diff --git a/test/http-api/spec/dns.js b/test/http-api/spec/dns.js new file mode 100644 index 0000000000..cd64feb3bd --- /dev/null +++ b/test/http-api/spec/dns.js @@ -0,0 +1,24 @@ +/* eslint-env mocha */ +'use strict' + +const expect = require('chai').expect + +module.exports = (http) => { + describe('/dns', () => { + let api + + before(() => { + api = http.api.server.select('API') + }) + + it('get the id', (done) => { + api.inject({ + method: 'GET', + url: '/api/v0/dns?arg=ipfs.io' + }, (res) => { + expect(res).to.have.property('Path') + done() + }) + }) + }) +}