/** @overview nodeunit test case. */

var testResource = require('../../../test_resource'),
    fs = require('fs'),
    path = require('path'),
    packNpmPackage = require('../../../../ci/worker/pack_npm_package.js');

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

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

//
exports['Pack npm package.'] = function (test) {
    testResource.prepareCleanWorkDirForTestFile(__filename, function (err, workDir) {
        var apemanfile = testResource.resolveMockFile('mock-Apemanfile.js');
        fs.readFile(apemanfile, function (err, buffer) {
            test.ifError(err);
            fs.writeFile(path.resolve(workDir, 'Apemanfile.js'), buffer, function () {
                packNpmPackage({
                    basedir: path.resolve(__dirname, workDir),
                    silent: true
                }, function (err) {
                    test.ifError(err);
                    test.done();
                });
            });
        });
    });
};