/** @overview nodeunit test case. */

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

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

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

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

exports['Get render data.'] = function (test) {
    generateTasksIndex._renderData(
        testResource.resolveMockFile('mock_modules'),
        function (err, data) {
            test.ifError(err);
            test.ok(data);
            test.done();
        }
    );
};

exports['Generate tasks index.'] = function (test) {
    testResource.prepareCleanWorkDirForTestFile(__filename, function (err, workDir) {
        generateTasksIndex({
            dir: workDir
        }, function (err) {
            test.ifError(err);
            test.done();
        });
    });
};