{"size": 2650, "ext": "js", "max_stars_repo_path": "test/minimize-failed.js", "max_stars_repo_name": "hamosapience/borschik-webp", "max_stars_repo_stars_event_min_datetime": null, "max_stars_repo_stars_event_max_datetime": null, "max_issues_repo_path": "test/minimize-failed.js", "max_issues_repo_name": "hamosapience/borschik-webp", "max_issues_repo_issues_event_min_datetime": "2020-05-14T15:02:57.000Z", "max_issues_repo_issues_event_max_datetime": "2020-05-15T15:24:52.000Z", "max_forks_repo_path": "test/minimize-failed.js", "max_forks_repo_name": "hamosapience/borschik-webp", "max_forks_repo_forks_event_min_datetime": "2016-11-26T07:57:08.000Z", "max_forks_repo_forks_event_max_datetime": "2016-11-26T07:57:08.000Z"}
{"max_stars_count": null, "max_issues_count": 1, "max_forks_count": 1, "avg_line_length": 28.4946236559, "max_line_length": 90, "alphanum_fraction": 0.4596226415}
describe('Useful info in case of failed minimize:', function() {

    var ASSERT = require('assert');
    var BORSCHIK = require('..');
    var FS = require('fs');
    var PATH = require('path');
    var VOW = require('vow');


    const testJS = PATH.resolve(__dirname, 'minimize-failed/fail.js');
    const testJSOut = PATH.resolve(__dirname, testJS + '.out');
    const testJSErrorFile = PATH.resolve(__dirname, testJSOut + '.borschik-error');

    const testCSS = PATH.resolve(__dirname, 'minimize-failed/fail.css');
    const testCSSOut = PATH.resolve(__dirname, testCSS + '.out');
    const testCSSErrorFile = PATH.resolve(__dirname, testCSSOut + '.borschik-error');

    afterEach(function() {
        try {
            FS.unlinkSync(testJSErrorFile);
        } catch(e) {}

        try {
            FS.unlinkSync(testCSSErrorFile);
        } catch(e) {}
    });

    it('should write file error result to "filename.borschik-error" (js)', function(cb) {

        BORSCHIK
            .api({
                'freeze': true,
                'input': testJS,
                'minimize': true,
                'output': testJSOut
            })
            .then(function() {
                cb('Successfully builded');
            })
            .fail(function(e) {
                try {
                    ASSERT.equal(FS.existsSync(testJSErrorFile), true);
                    cb();
                } catch(e) {
                    cb(e);
                }
            });

    });

    it('should reject with error when process string (js)', function() {

        // proccess it
        return BORSCHIK
            .api({
                'freeze': true,
                'inputString': FS.readFileSync(testJS, 'utf-8'),
                'basePath': PATH.dirname(testJS),
                'minimize': true,
                'tech': 'js'
            })
            .then(function() {
                return VOW.reject('passed');
            }, function() {
                return VOW.resolve();
            });
    });

    it('should write file error result to "filename.borschik-error" (css)', function(cb) {

        BORSCHIK
            .api({
                'freeze': true,
                'input': testCSS,
                'minimize': true,
                'output': testCSSOut
            })
            .then(function() {
                cb('Successfully builded');
            })
            .fail(function(e) {
                try {
                    ASSERT.equal(FS.existsSync(testCSSErrorFile), true);
                    cb();
                } catch(e) {
                    cb(e);
                }
            });

    });

});
