(function() {
    'use strict';
    
    let readify = require('..'),
        test    = require('tape'),
        exec    = require('execon');
    
    test('path: wrong', t => {
        readify('/wrong/path', (error) => {
            t.ok(error, error.message);
            t.end();
        });
    });
    
    test('path: correct', t => {
        readify('.', (error, json) => {
            t.notOk(error, 'no error');
            
            t.ok(json, 'json');
            t.equal(typeof json.path, 'string');
            t.ok(Array.isArray(json.files));
            
            t.end();
        });
    });
    
    test('result: should be sorted by name folders then files', function(t) {
        readify('.', (error, json) => {
            t.notOk(error, 'no error');
            
            let all   = json.files,
                
                isDir   = file => file.size === 'dir',
                
                not     = function(fn) {
                    return function() {
                        fn.apply(null, arguments);
                    };
                },
                
                isFile  = not(isDir),
                
                files   = all.filter(isFile),
                dirs    = all.filter(isDir),
                
                names   = dirs
                    .concat(files)
                    .map(file => 
                        file.name
                    ),
                    
                sorted = names.sort((a, b) =>
                    a > b ? 1 : -1
                );
            
            t.deepEqual(names, sorted);
            
            t.end();
        });
    });
    
    test('result: files should have fields name, size, owner, mode', t => {
        readify('.', (error, json) => {
            let files       = json.files,
                length      = files.length,
                check       = () =>
                    files.filter((file) => 
                        Object.keys(file).join(':') === 'name:size:owner:mode'
                    ).length;
            
            t.notOk(error, 'no error');
            
            t.equal(check(), length, 'files array do not have fields: name, size, owner, mode');
        
        t.end();
        });
    });
    
    test('arguments: exception when no path', t => {
       t.throws(readify, /path should be string!/, 'should throw when no path');
       t.end();
    });
    
    test('arguments: exception when no callback', t => {
        var noCallback = exec.with(readify, '.');
        
       t.throws(noCallback, /callback should be function!/, 'should throw when no callback');
       t.end();
    });
})();

@@ -2249,32 +2249,600 @@
 );%0A    %7D);%0A    %0A
+    test('result: file names should not be empty', t =%3E %7B%0A        readify('.', (error, json) =%3E %7B%0A            let files       = json.files,%0A                check       = () =%3E%0A                    files.filter((file) =%3E %0A                        !file.name%0A                    ).forEach(file =%3E %7B%0A                        throw Error('Filename should not be empty!%5Cn' + JSON.stringify(file));%0A                    %7D);%0A            %0A            t.notOk(error, 'no error');%0A            t.doesNotThrow(check, 'should not throw');%0A            t.end();%0A        %7D);%0A    %7D);%0A    %0A
     test('argume

test(readify) when name is empty