Code coverage report for test/minify_each_spec.js

Statements: 93.94% (31 / 33)      Branches: 100% (0 / 0)      Functions: 75% (6 / 8)      Lines: 93.94% (31 / 33)     

All files » test/ » minify_each_spec.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 741     1   1   1   1 2   2           2                       2     1   1 1       1   1     1 1     1 1   1 1 1   1 1     1 1   1 1 1   1 1 1        
var grunt = require( "grunt" ),
    _ = grunt.util._;
 
describe( "minify each test", function () {
 
    var MinifyEach = require( "../tasks/lib/MinifyEach" );
 
    var minify = require( "../tasks/minify_each" );
 
    var makeMockTask = function ( done ) {
        var o, taskOptions;
 
        taskOptions = {
            dest: 'build',
            minDest: 'min',
            type: 'uglifyjs',
            parameters: [ '--max-line-len=10000', '--lift-vars', '-m' ]
        };
        o = {
            files: [ {
                src: grunt.file.expand( {}, "tasks/**/*.js" )
            } ],
            type: 'uglifyjs',
            options: function ( defs ) {
                return _.defaults( taskOptions, defs );
            },
            async: function () {
                return done;
            }
        };
        return o;
    };
 
    it( "test node require includes", function () {
 
        expect( minify ).toNotEqual( undefined );
        expect( MinifyEach ).toNotEqual( undefined );
 
    } );
 
    it( "registers itself with grunt", function () {
 
        minify( grunt );
 
        // Check that it registered
        expect( grunt.task._tasks[ MinifyEach.TASK_NAME ] ).toNotEqual( undefined );
        expect( grunt.task._tasks[ MinifyEach.TASK_NAME ].info ).toEqual( MinifyEach.TASK_DESCRIPTION );
    } );
 
    it( "loads options from a task", function () {
        var mock, task, files, actual;
 
        mock = makeMockTask();
        task = new MinifyEach( mock, mock, mock.files );
        actual = task.options;
 
        expect( actual ).toNotEqual( undefined );
        expect( actual.engine ).toEqual( task.Defaults.engine );
    } );
 
    it( "run MinifyEach ", function () {
        var mock, files, task;
 
        mock = makeMockTask();
        console.error( mock.files );
        task = new MinifyEach( mock, mock, mock.files );
 
        spyOn( task, 'processFiles' ).andCallThrough();
        task.processFiles();
        expect( task.processFiles ).toHaveBeenCalled();
 
    } );
} );