From a71308c587239cbee71afc8f88b8ba224ce2d16b Mon Sep 17 00:00:00 2001 From: Hans Kristian Flaatten Date: Wed, 6 Jul 2016 22:24:38 +0200 Subject: [PATCH] fix(test): use os specific path seperators --- package.json | 6 +++--- test/index.js | 17 +++++++++++++---- test/support/env.js | 4 +++- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 61478dc..d6d4f81 100644 --- a/package.json +++ b/package.json @@ -8,13 +8,13 @@ ], "scripts": { "codacy-coverage": "codacy-coverage", - "cover": "istanbul cover --report lcovonly ./node_modules/.bin/_mocha -- -r test/support/env test/**", + "cover": "istanbul cover --report lcovonly ./node_modules/.bin/_mocha -- -r test/support/env test", "lint": "eslint index.js test", "nsp": "nsp check", "semantic-release": "semantic-release", "start": "supervisor index.js", - "test": "mocha -b -c --check-leaks -R tap -r test/support/env test/**", - "test:watch": "mocha -w -b -c --check-leaks -R progress -r test/support/env test/**", + "test": "mocha -b -c --check-leaks -R tap -r test/support/env test", + "test:watch": "mocha -w -b -c --check-leaks -R progress -r test/support/env test", "greenkeeper-postpublish": "greenkeeper-postpublish" }, "repository": { diff --git a/test/index.js b/test/index.js index 22b3e30..d227cc8 100644 --- a/test/index.js +++ b/test/index.js @@ -8,6 +8,7 @@ const S3 = require('aws-sdk').S3; const ReadStream = require('fs').ReadStream; const statSync = require('fs').statSync; const unlinkSync = require('fs').unlinkSync; +const pathSep = require('path').sep; const randomPath = require('@starefossen/rand-path'); @@ -183,14 +184,18 @@ describe('Image', () => { let image; beforeEach(() => { - image = new Upload.Image(`${__dirname}/assets/photo.jpg`, {}, upload); + const file = [__dirname, 'assets', 'photo.jpg'].join(pathSep); + + image = new Upload.Image(file, {}, upload); image.upload._randomPath = () => '110ec58a-a0f2-4ac4-8393-c866d813b8d1'; }); describe('constructor', () => { it('sets default values', () => { + const file = [__dirname, 'assets', 'photo.jpg'].join(pathSep); + assert(image instanceof Upload.Image); - assert.equal(image.src, `${__dirname}/assets/photo.jpg`); + assert.equal(image.src, file); assert.deepEqual(image.opts, {}); assert(image.upload instanceof Upload); }); @@ -369,6 +374,7 @@ describe('Image', () => { describe('#getMetadata()', () => { it('returns image metadata without exif data', done => { image.upload.opts.returnExif = false; + console.log('getMetadata', image.src); image.getMetadata(image.src, (err, metadata) => { assert.ifError(err); assert.deepEqual(metadata, { @@ -594,7 +600,10 @@ describe('Integration Tests', () => { it('uploads image to new random path', function it(done) { this.timeout(10000); - upload.upload(`${__dirname}/assets/portrait.jpg`, {}, (e, images) => { + + const file = [__dirname, 'assets', 'portrait.jpg'].join(pathSep); + + upload.upload(file, {}, (e, images) => { assert.ifError(e); images.forEach(image => { @@ -626,7 +635,7 @@ describe('Integration Tests', () => { it('uploads image to fixed path', function it(done) { this.timeout(10000); - const file = `${__dirname}/assets/portrait.jpg`; + const file = [__dirname, 'assets', 'portrait.jpg'].join(pathSep); const opts = { path: 'path/to/image', }; diff --git a/test/support/env.js b/test/support/env.js index 55f0aa1..f81342f 100644 --- a/test/support/env.js +++ b/test/support/env.js @@ -1,3 +1,5 @@ 'use strict'; -process.env.TMP_DIR = '/tmp'; +const tmpdir = require('os').tmpdir; + +process.env.TMP_DIR = tmpdir();