src/service/page.test-helper.js
/**
            * Use this to manually create directives for testing. This only creates the directive. Methods to access and manipulate it should be in a
            * page accessor object corresponding to the directive. 
            * 
            * check zGrid.directive.spec.js,   and its accessors zGridAccessors
            *
            * @param {Object} set of options used to configure directive construction:
            * 
            *        {String} html (required) The HTML used to construct the directive.
            *        {Object} accessors class which should define all methods to access html elements made available after compilation of the code
            *        {Object} scope (optional) The scope to construct the directive element with. This is not the directive scope.
            *        {String} vm (optional) the name of the controller in this page. 
            * 
            * @return {object} The constructed page. Exposes:
            *         {Object} element : The compiled directive element.
            *         {Object} scope : The scope of the compiled directive.
            *         {methods} all accessors are accessible from this page object directly.
            *         
            */
Use this to manually create directives for testing. This only creates the directive. Methods to access and manipulate it should be in a
page accessor object corresponding to the directive.

check zGrid.directive.spec.js,   and its accessors zGridAccessors

@param {Object} set of options used to configure directive construction.

{String} html (required) The HTML used to construct the directive.
{Object} accessors class which should define all methods to access html elements made available after compilation of the code
{Object} scope (optional) The scope to construct the directive element with. This is not the directive scope.
{String} vm (optional) the name of the controller in this page.

@return {object} The constructed page. Exposes:
{Object} element : The compiled directive element.
{Object} scope : The scope of the compiled directive.
{methods} all accessors are accessible from this page object directly.
Use this to manually create directives for testing . This only creates the directive . Methods to access and manipulate it should be in a page accessor object corresponding to the directive . check zGrid . directive . spec . js and its accessors zGridAccessors @param { Object } set of options used to configure directive construction . { String } html ( required ) The HTML used to construct the directive . { Object } accessors class which should define all methods to access html elements made available after compilation of the code { Object } scope ( optional ) The scope to construct the directive element with . This is not the directive scope . { String } vm ( optional ) the name of the controller in this page . @return { object } The constructed page . Exposes : { Object } element : The compiled directive element . { Object } scope : The scope of the compiled directive . { methods } all accessors are accessible from this page object directly .
function buildPage(options, noDigest) {
        if (options.vm && !options.scope[options.vm]) {
            options.scope[options.vm] = {};
        }
        var element = $('<div>');
        element.append(options.html);
        $compile(element)(options.scope);
        if (!noDigest) {
            options.scope.$digest();
        }
        var page = {
            element: element,
            scope: options.scope,
            $digest: function (debug) {
                options.scope.$digest();
                if (debug) {
                    page.print();
                }
            },
            print: function () {
                console.log('----------------------- P A G E --------------------------');
                console.log($('<div>').append(element).clone().html());
                console.log('----------------------------------------------------------');
            }
        };
        if (options.vm) {
            page[options.vm] = page.scope[options.vm];
        }
        return _.assign(page, new options.accessors(element));
    }
function buildPage ( options , noDigest ) { if ( options . vm && ! options . scope [ options . vm ] ) { options . scope [ options . vm ] = { } ; } var element = $ ( '<div>' ) ; element . append ( options . html ) ; $compile ( element ) ( options . scope ) ; if ( ! noDigest ) { options . scope . $digest ( ) ; } var page = { element : element , scope : options . scope , $digest : function ( debug ) { options . scope . $digest ( ) ; if ( debug ) { page . print ( ) ; } } , print : function ( ) { console . log ( '----------------------- P A G E --------------------------' ) ; console . log ( $ ( '<div>' ) . append ( element ) . clone ( ) . html ( ) ) ; console . log ( '----------------------------------------------------------' ) ; } } ; if ( options . vm ) { page [ options . vm ] = page . scope [ options . vm ] ; } return _ . assign ( page , new options . accessors ( element ) ) ; }
Use this to manually create directives for testing.
Use this to manually create directives for testing .
// only create the vm if it does not exist