// fis.baidu.com

var assert = require('assert');
var fis = require('..');
var path = require('path');
var root = path.join(__dirname, 'project');

require.del = function (id) {
  try {
    var path = require.resolve(id);
    delete require.cache[path];
  } catch(e) {}
};

describe('project: const variable', function () {
  var project = require('../lib/project');
  it ('DEFAULT_REMOTE_REPOS', function () {
    assert.equal(project.DEFAULT_REMOTE_REPOS, 'http://fis.baidu.com/repos');
  });
});

describe('project: tempPath', function () {
  var project;
  beforeEach(function () {
    require.del('../lib/project');
    project = require('../lib/project');
  });

  it ('setTempRoot', function () {
    var pth = path.join(root, '.fis-tmp');
    project.setTempRoot(pth);
    assert.equal(project.getTempPath(), pth);
  });

  it ('getTempPath', function () {
    var tempPath = project.getTempPath();
    if (fis.util.isWin()) {
      //@TODO
    } else {
      assert.equal(tempPath, process.env['HOME'] + '/.fis-tmp');
    }
  })
});

describe('project: projectPath', function () {
  var project;
  beforeEach(function () {
    require.del('../lib/project');
    project = require('../lib/project');
  });

  //@TODO
  /*
  it('getProjectPath', function () {
    try {
      project.getProjectPath();
    }  catch (e) {
      //
    }
  });
  */

  it('setProjectRoot', function () {
    project.setProjectRoot(root);
    assert.equal(project.getProjectPath(), root);
  });
});
@@ -1466,20 +1466,910 @@
 (), root);%0A  %7D);%0A%7D);
+%0A%0Adescribe('project: getSource', function () %7B%0A  var project;%0A  beforeEach(function () %7B%0A    fis.config.init(); // @TODO%0A    fis.media().init(); // @TODO%0A    require.del('../lib/project');%0A    project = require('../lib/project');%0A  %7D);%0A%0A  //@TODO%0A  it('getSourceByPatterns', function () %7B%0A  %7D);%0A%7D);%0A%0Adescribe('project: lookup', function () %7B%0A  var project;%0A  beforeEach(function () %7B%0A    fis.config.init(); // @TODO%0A    fis.media().init(); // @TODO%0A    require.del('../lib/project');%0A    project = require('../lib/project');%0A    project.setProjectRoot(root);%0A  %7D);%0A%0A  it(%22not event%22, function () %7B%0A    var filepath = path.join(root, 'test.js');%0A    fis.util.write(filepath, 'console.log(%22hello, world.%22);');%0A    var info = project.lookup('/test.js');%0A    assert.deepEqual(%7Bid: info.id, moduleId: info.moduleId%7D, %7Bid: '/test.js', moduleId: '/test.js'%7D);%0A    fis.util.del(filepath);%0A  %7D);%0A%7D);

update test