Permalink
Browse files

Add tests for scenario when config exists in home directory but not i…

…n current directory.
  • Loading branch information...
1 parent 1b965a8 commit 392d3774028b2b20cc6dd6c14c8c2c260c5f77ce @cliffano committed May 17, 2012
Showing with 20 additions and 9 deletions.
  1. +20 −9 test/cli.js
View
@@ -217,30 +217,41 @@ describe('cli', function () {
checks.fs_readFileSync_file.should.equal('/home/blah/.conf.json');
});
- it('should return file content in home directory when all files exist and platform is windows', function () {
+ it('should return file content in current directory when it exists but none exists in home directory', function () {
mocks = {
- process_platform: 'win32',
- process_env: { USERPROFILE: '/home/blah' },
+ process_env: { HOME: '/home/blah' },
process_cwd: '/curr/dir',
- 'fs_readFileSync_/home/blah/.conf.json': 'homedirfilecontent',
'fs_readFileSync_/curr/dir/.conf.json': 'currdirfilecontent'
};
mocks.requires = { fs: bag.mock.fs(checks, mocks) };
cli = create(checks, mocks);
+ cli.readConfigFileSync('.conf.json').should.equal('currdirfilecontent');
+ checks.fs_readFileSync_file.should.equal('/curr/dir/.conf.json');
+ });
+
+ it('should return file content in home directory when it exists but none exists in current directory and platform is non-windows', function () {
+ mocks = {
+ process_env: { HOME: '/home/blah' },
+ process_cwd: '/curr/dir',
+ 'fs_readFileSync_/home/blah/.conf.json': 'homedirfilecontent'
+ };
+ mocks.requires = { fs: bag.mock.fs(checks, mocks) };
+ cli = create(checks, mocks);
cli.readConfigFileSync('.conf.json').should.equal('homedirfilecontent');
checks.fs_readFileSync_file.should.equal('/home/blah/.conf.json');
});
- it('should return file content in current directory when it exists but not in home directory', function () {
+ it('should return file content in home directory when it exists but none exists in current directory and platform is windows', function () {
mocks = {
- process_env: { HOME: '/home/blah' },
+ process_platform: 'win32',
+ process_env: { USERPROFILE: '/home/blah' },
process_cwd: '/curr/dir',
- 'fs_readFileSync_/curr/dir/.conf.json': 'currdirfilecontent'
+ 'fs_readFileSync_/home/blah/.conf.json': 'homedirfilecontent'
};
mocks.requires = { fs: bag.mock.fs(checks, mocks) };
cli = create(checks, mocks);
- cli.readConfigFileSync('.conf.json').should.equal('currdirfilecontent');
- checks.fs_readFileSync_file.should.equal('/curr/dir/.conf.json');
+ cli.readConfigFileSync('.conf.json').should.equal('homedirfilecontent');
+ checks.fs_readFileSync_file.should.equal('/home/blah/.conf.json');
});
it('should throw an error when configuration file does not exist anywhere', function () {

0 comments on commit 392d377

Please sign in to comment.