Skip to content

Commit

Permalink
Cleaned up tests a bit.
Browse files Browse the repository at this point in the history
  • Loading branch information
shannonmoeller committed May 5, 2015
1 parent 173ceac commit e62c50c
Showing 1 changed file with 17 additions and 6 deletions.
23 changes: 17 additions & 6 deletions test/find-config.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

var findConfig = require('../index'),
expect = require('expect'),
path = require('path');
path = require('path'),
nofile = 'find-config-3da35411-9d24-4dec-a7cb-3cb9416db670';

describe('require-glob e2e', function () {
beforeEach(function () {
Expand Down Expand Up @@ -49,7 +50,7 @@ describe('require-glob e2e', function () {
expect(findConfig('a.txt', options)).toBe(path.resolve('../../a.txt'));
});

it('should drop leading dots in .config directories', function () {
it('should drop leading dots in .dir', function () {
var options = { cwd: 'fixtures/a/b' };

expect(findConfig('.fred', options)).toBe(null);
Expand All @@ -61,7 +62,7 @@ describe('require-glob e2e', function () {
expect(findConfig('.waldo')).toBe(path.resolve('../../.config/waldo'));
});

it('should keep leading dots in .config directories', function () {
it('should keep leading dots in .dir', function () {
var options = { cwd: 'fixtures/a/b', keepDot: true };

expect(findConfig('.fred', options)).toBe(path.resolve('fixtures/.config/.fred'));
Expand Down Expand Up @@ -90,26 +91,36 @@ describe('require-glob e2e', function () {
it('should not find non-existant files', function () {
expect(findConfig()).toBe(null);
expect(findConfig(null)).toBe(null);
expect(findConfig('find-config-3da35411-9d24-4dec-a7cb-3cb9416db670')).toBe(null);
expect(findConfig(nofile)).toBe(null);
});

describe('read', function () {
it('should read files', function () {
var options = { cwd: 'fixtures/a/b' };

expect(findConfig.read()).toBe(null);
expect(findConfig.read('foo.txt', options)).toBe('foo\n');
expect(findConfig.read('baz.txt', options)).toBe('baz\n');
});

it('should not read non-existant files', function () {
expect(findConfig.read()).toBe(null);
expect(findConfig.read(null)).toBe(null);
expect(findConfig.read(nofile)).toBe(null);
});
});

describe('require', function () {
it('should require files', function () {
var options = { cwd: 'fixtures/a/b' };

expect(findConfig.require()).toBe(null);
expect(findConfig.require('b', options)).toEqual({ a: 1 });
expect(findConfig.require('baz', options)).toEqual({ b: 2 });
});

it('should not require non-existant files', function () {
expect(findConfig.require()).toBe(null);
expect(findConfig.require(null)).toBe(null);
expect(findConfig.require(nofile)).toBe(null);
});
});
});

0 comments on commit e62c50c

Please sign in to comment.