/** @overview nodeunit test case. */

var testResource = require('../../../test_resource'),
    generateColorLess = require('../../../../task/worker/generate_color_less.js');

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

exports.tearDown = function (done) {
    done();
};
exports['Resolve pattern.'] = function (test) {
    var pattern = '{{variation}}-{{scheme}}/{{variation}}-{{scheme}}-color-scheme-theme-{{theme}}.less';
    var resolved = generateColorLess._resolvePattern(pattern, {
        variation: 'pale',
        scheme: 'constraint',
        theme: 'b'
    });
    test.ok(resolved);
    test.done();
};

exports['Generate color less.'] = function (test) {
    var pattern = require('path').resolve(__dirname, '../../../../clientside/src/less_themes/variable/color_scheme/')
        + '/{{variation}}-{{scheme}}/{{variation}}-{{scheme}}-color-scheme-theme-{{theme}}.less';
    generateColorLess({
        dest: testResource.resolveWorkFile('work_generate_color_less.less'),
        settingFile: testResource.resolveMockFile('mock-style-color-setting.json'),
        srcPattern: pattern
    }, function (err) {
        test.ifError(err);
        test.done();
    });
};
exports['Handle errors.'] = function (test) {
    generateColorLess({
        dest: '',
        settingFile: testResource.resolveMockFile('mock-style-color-setting.json'),
        srcPattern: 'foo/bar/_not_exists'
    }, function (err) {
        test.ok(err);
        test.done();
    });
};