/** @overview nodeunit test case. */

var testResource = require('../../../test_resource'),
    mockInjector = require('../../../mock_injector'),
    generateTaskDefineHelper = require('../../../../ci/worker/generate_task_define_helper.js');

exports.setUp = function (done) {
    done();
};

exports.tearDown = function (done) {
    mockInjector.restoreAll();
    done();
};

exports['Load the template.'] = function (test) {
    generateTaskDefineHelper._loadTaskDefineHelperTmpl(function (err, tmpl) {
        test.ifError(err);
        test.ok(tmpl);
        test.done();
    });
};

exports['Load the test template.'] = function (test) {
    generateTaskDefineHelper._loadTaskDefineHelperTestTmpl(function (err, tmpl) {
        test.ifError(err);
        test.ok(tmpl);
        test.done();
    });
};

exports['Write a test file.'] = function (test) {
    var dest = testResource.resolveWorkFile('work_task_define_helper_test.js');
    generateTaskDefineHelper._writeTestFile(dest, {
        modulePath: 'foo',
        moduleName: 'foo'
    }, function (err) {
        test.ifError(err);
        test.done();
    });
};

exports['Should ignore.'] = function (test) {
    test.ok(generateTaskDefineHelper._shouldIgnore('index.js'));
    test.ok(generateTaskDefineHelper._shouldIgnore('.DS_STORE'));
    test.ok(generateTaskDefineHelper._shouldIgnore('.svn'));
    test.ok(generateTaskDefineHelper._shouldIgnore('.private'));
    test.ok(!generateTaskDefineHelper._shouldIgnore('do_something.js'));
    test.done();
};

exports['Generate task define helper.'] = function (test) {
    generateTaskDefineHelper({
        workerDir: testResource.resolveMockFile('mock_modules2'),
        dest: testResource.resolveWorkFile('work_generate_task_define_helper.js')
    }, function (err) {
        test.ifError(err);
        test.done();
    });
};