From ca78f6efdb565f39b94a0877d7977543551e049f Mon Sep 17 00:00:00 2001 From: raub Date: Sat, 5 May 2018 17:15:16 +0300 Subject: [PATCH] :arrow_up: :white_check_mark: :shirt: Prepare for release --- package.json | 4 ++-- test/test.js | 35 ++++++++++++++++++++++++++++------- 2 files changed, 30 insertions(+), 9 deletions(-) diff --git a/package.json b/package.json index 923e0d5..e50de92 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "author": "Luis Blanco ", "name": "addon-tools-raub", - "version": "0.1.9", + "version": "1.0.0", "description": "Helpers for Node.js addons and dependency packages", "license": "MIT", "main": "index.js", @@ -28,6 +28,6 @@ "url": "https://github.com/node-3d/addon-tools-raub.git" }, "dependencies": { - "nan": "2.10.0" + "nan": "~2.10.0" } } diff --git a/test/test.js b/test/test.js index 0aa167a..41eb4e6 100644 --- a/test/test.js +++ b/test/test.js @@ -9,7 +9,7 @@ const { stub, spy } = require('sinon'); const tools = require('addon-tools-raub'); -const toolsDir = path.dirname(require.resolve('addon-tools-raub')).replace(/\\/g, '/') +const toolsDir = path.dirname(require.resolve('addon-tools-raub')).replace(/\\/g, '/'); const allMethods = ['paths', 'root', 'include', 'mkdir', 'rm', 'cp']; const ownMethods = allMethods.slice(1); const cmdMethods = allMethods.slice(3); @@ -22,14 +22,14 @@ describe('Tools', () => { let stubbed; beforeEach(() => { log = spy(); - stubbed = stub(console, 'log').callsFake(log) + stubbed = stub(console, 'log').callsFake(log); }); afterEach(() => stubbed.restore()); describe('Own Methods', () => { - allMethods.forEach( + ownMethods.forEach( m => it(`#${m}() is available`, () => { expect(tools).to.respondTo(m); }) @@ -46,19 +46,19 @@ describe('Tools', () => { ); - it(`#root() is correct`, () => { + it('#root() is correct', () => { tools.root(); expect(log.getCall(0).args[0]).to.equal(toolsDir); }); - it(`#include() is correct`, async () => { + it('#include() is correct', async () => { tools.include(); const dirs = log.getCall(0).args[0].split(' '); const stats = await Promise.all(dirs.map(dir => new Promise( - (res, rej) => fs.stat( + res => fs.stat( dir, (err, stat) => err ? res(false) : res(stat.isDirectory()) ) @@ -71,9 +71,30 @@ describe('Tools', () => { }); + describe('Cmd Methods', () => { + + cmdMethods.forEach( + m => it(`#${m}() is available`, () => { + expect(tools).to.respondTo(m); + }) + ); + + + cmdMethods.forEach( + m => it(`#${m}() writes stdout`, () => { + tools[m](); + expect(log.getCall(0), 'called').to.exist; + expect(log.getCall(0).args[0], 'has args').to.exist; + expect(log.getCall(0).args[0], 'writes string').to.be.a('string'); + }) + ); + + }); + + describe('Paths', () => { - it(`#paths() returns an object`, () => { + it('#paths() returns an object', () => { expect(tools.paths(__dirname)).to.be.an('object'); });