Skip to content

Commit

Permalink
chore(test/utils): add factory for ngModule
Browse files Browse the repository at this point in the history
  • Loading branch information
Hotell committed Jun 11, 2016
1 parent 253a986 commit 89ef73c
Showing 1 changed file with 46 additions and 0 deletions.
46 changes: 46 additions & 0 deletions test/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,52 @@ import { isArray, isFunction, assign } from '../src/facade/lang';
// _private helpers for testing
// ============================

export function createNgModule() {
return {
module( name, requires?: string[] ){
const _m = {
requires: [],
name: name
};
if ( requires ) {
_m.requires = requires;
// setter
} else {
// getter
}

return {
name: _m.name,
requires: _m.requires,
_configBlocks: [],
_invokeQueue: [],
_runBlocks: [],

constant(n,v){ this._invokeQueue.push(['$provide','constant',[n,v]]); return this; },
value(n,v){ this._invokeQueue.push(['$provide','value',n,v]); return this; },
provider(n,v){ this._invokeQueue.push(['$provide','provider',[n,v]]); return this; },
factory(n,v){ this._invokeQueue.push(['$provide','factory',[n,v]]); return this; },
service(n,v){ this._invokeQueue.push(['$provide','service',[n,v]]); return this; },
decorator(n,v){ this._configBlocks.push(['$provide','decorator',[n,v]]); return this; },

directive(n,v){ this._invokeQueue.push(['$compileProvider','directive',[n,v]]); return this; },
component(n,v){ this._invokeQueue.push(['$compileProvider','component',[n,v]]); return this; },

controller(n,v){ this._invokeQueue.push(['$controllerProvider','register',[n,v]]); return this; },

filter(n,v){ this._invokeQueue.push(['$filterProvider','register',[n,v]]); return this; },


animation(n,v){ this._invokeQueue.push(['$animateProvider','register',[n,v]]); return this; },

config(v){ this._configBlocks.push(['$injector','invoke',[v]]); return this; },
run(v){ this._runBlocks.push(v); return this; },
}

}
}
}

/**
*
* @internal
Expand Down

0 comments on commit 89ef73c

Please sign in to comment.