Skip to content

Commit

Permalink
fix(test): use os specific path seperators
Browse files Browse the repository at this point in the history
  • Loading branch information
Hans Kristian Flaatten committed Jul 6, 2016
1 parent 8e03d30 commit a71308c
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 8 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
17 changes: 13 additions & 4 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');

Expand Down Expand Up @@ -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);
});
Expand Down Expand Up @@ -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, {
Expand Down Expand Up @@ -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 => {
Expand Down Expand Up @@ -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',
};
Expand Down
4 changes: 3 additions & 1 deletion test/support/env.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
'use strict';

process.env.TMP_DIR = '/tmp';
const tmpdir = require('os').tmpdir;

process.env.TMP_DIR = tmpdir();

0 comments on commit a71308c

Please sign in to comment.