it('can get config from cli args', function() { mockFs({ 'foo.yml': '', }) var res = codecov.upload({ options: { dump: true, yml: 'foo.yml', disable: 'detect' }, }) var CWD = process .cwd() .toString() .replace(/\\/g, '/') expect(res.query.yaml.toString().replace(/\\/g, '/')).toBe(CWD + '/foo.yml') mockFs.restore() })
mockFs(dirs) { helpers._getFile = function(path) { const contents = fs.readFileSync(path, 'utf-8').replace('module.exports = ', ''); return eval('(' + contents + ')'); }; mockFs(dirs); }
it('can read a .codecov.yml file', function() { mockFs({ '.codecov.yml': 'codecov:\n token: fake-token-dotfile', }) expect(codecov.upload({ options: { dump: true } }).query.token).toBe( 'fake-token-dotfile' ) mockFs.restore() })
function buildMockSetup(configurePath) { return { topic: function(passthrough) { mockFs({ '/tmp': mockFs.directory() }); return passthrough; }, teardown: function(app) { mockFs.restore(); return true; }, 'it works': function(err, app) { assert.ifError(err); } }; }
beforeEach(function() { mockFs({ '/fake_dir': { 'example_file.md': 'example content.', 'another_example_file.md': 'example content.', 'another_dir': { 'a.js': '...', 'b.md': mockFs.symlink({ path: '/fake_dir/another_example_file.md' }) }, } }, { createCwd: false }); });
mockFs(testCase.directories);
describe('fs methods', () => { beforeEach(() => { mockFs({ '/fake_dir': { 'example_file.md': 'example content.',
mockFs({ '/fake_dir': { 'example_file.md': 'example content.',
beforeEach(function() { mockFs({ '/fake_dir': { 'example_file.md': 'example content.', 'empty_dir': {}, 'empty_dir2': {}, 'non_empty_dir': { 'file.rb': 'content', 'foo': { 'bar.js': {} }, '.git': {} }, 'non_empty_dir2': { 'file.md': 'content' } } }, { // add this option otherwise node-glob returns an empty string! createCwd: false }); });
it('can read a codecov.yml file', function() { mockFs({ 'codecov.yml': 'codecov:\n token: fake-token', }) expect(codecov.upload({ options: { dump: true } }).query.token).toBe( 'fake-token' ) mockFs.restore() })
it('should have no token if yaml file does not supplied', function() { mockFs({ '.codecov.yml': 'codecov:\n noconfig: true', }) expect(codecov.upload({ options: { dump: true } }).query.token).toBe( undefined ) mockFs.restore() })
beforeEach(function() { mockFs({ '/fake_dir': { 'example_file.md': 'example content.', 'another_example_file.md': 'example content.', 'another_dir': { 'a.js': '...', 'b.js': '...', 'c.php': '...', 'k.php': '...', 'd.html': '...', 'g.md': mockFs.symlink({ path: '/fake_dir/example_file.md' }), 'README.md': '...', 'document.txt': '...', '.dir': {}, 'foo.rb': '...' }, } }); });
beforeEach(function() { mockFs({ '/fake_dir': { 'example_file.md': 'example content.', 'another_example_file.md': 'example content.', 'another_dir': { 'a.js': '...', 'b.js': '...', 'c.php': 'c.php content!', 'd.html': '...', 'document.txt': '...', 'foo.rb': '...', 'g.md': mockFs.symlink({ path: '/fake_dir/example_file.md' }), 'k.php': '...', 'README.md': '...', '.git': {}, }, 'store': { 'c.php': 'backup c.php content!' } } }, { // add this option otherwise node-glob returns an empty string! createCwd: false }); });