style: fix code style

This commit is contained in:
Gajus Kuizinas
2016-11-01 15:26:29 +00:00
parent 7990da993f
commit 858085656b
17 changed files with 320 additions and 321 deletions
+36 -36
View File
@@ -1,47 +1,47 @@
/* eslint-disable max-nested-callbacks */
import path from 'path';
import {
expect
} from 'chai';
import path from 'path';
import validateTargetDirectory from './../src/utilities/validateTargetDirectory';
import validateTargetDirectory from '../src/utilities/validateTargetDirectory';
const fixturesPath = path.resolve(__dirname, './../../fixtures/validate-target-directory');
const fixturesPath = path.resolve(__dirname, '../fixtures/validate-target-directory');
describe('validateTargetDirectory()', () => {
describe('directory path', () => {
context('refers to a directory that does not exist', () => {
it('throws an error', () => {
expect(() => {
validateTargetDirectory(path.resolve(fixturesPath, 'does-not-exist'));
}).to.throw(Error, 'Directory "' + path.resolve(fixturesPath, 'does-not-exist') + '" does not exist.');
});
});
context('refers to a file', () => {
it('throws an error', () => {
expect(() => {
validateTargetDirectory(path.resolve(fixturesPath, 'not-a-directory.js'));
}).to.throw(Error, '"' + path.resolve(fixturesPath, 'not-a-directory.js') + '" is not a directory.');
});
});
describe('directory path', () => {
context('refers to a directory that does not exist', () => {
it('throws an error', () => {
expect(() => {
validateTargetDirectory(path.resolve(fixturesPath, 'does-not-exist'));
}).to.throw(Error, 'Directory "' + path.resolve(fixturesPath, 'does-not-exist') + '" does not exist.');
});
});
describe('target index', () => {
context('no index', () => {
it('returns true', () => {
expect(validateTargetDirectory(path.resolve(fixturesPath, 'no-index'))).to.equal(true);
});
});
context('safe', () => {
it('returns true', () => {
expect(validateTargetDirectory(path.resolve(fixturesPath, 'safe-index'))).to.equal(true);
});
});
context('unsafe', () => {
it('throws an error', () => {
expect(() => {
validateTargetDirectory(path.resolve(fixturesPath, 'unsafe-index'));
}).to.throw(Error, '"' + path.resolve(fixturesPath, 'unsafe-index/index.js') + '" unsafe index.');
});
});
context('refers to a file', () => {
it('throws an error', () => {
expect(() => {
validateTargetDirectory(path.resolve(fixturesPath, 'not-a-directory.js'));
}).to.throw(Error, '"' + path.resolve(fixturesPath, 'not-a-directory.js') + '" is not a directory.');
});
});
});
describe('target index', () => {
context('no index', () => {
it('returns true', () => {
expect(validateTargetDirectory(path.resolve(fixturesPath, 'no-index'))).to.equal(true);
});
});
context('safe', () => {
it('returns true', () => {
expect(validateTargetDirectory(path.resolve(fixturesPath, 'safe-index'))).to.equal(true);
});
});
context('unsafe', () => {
it('throws an error', () => {
expect(() => {
validateTargetDirectory(path.resolve(fixturesPath, 'unsafe-index'));
}).to.throw(Error, '"' + path.resolve(fixturesPath, 'unsafe-index/index.js') + '" unsafe index.');
});
});
});
});