File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -76,4 +76,21 @@ describe('Plugins', function() {
7676 instances [ 1 ] . should . not . have . property ( 'dirty' )
7777 } , done )
7878 } )
79+
80+ it ( 'throws an error if a register property is not a function' , function ( done ) {
81+ let app = new Microcosm ( )
82+
83+ let Plugin = {
84+ register : 'booyah'
85+ }
86+
87+ app . addPlugin ( Plugin )
88+
89+ try {
90+ app . start ( )
91+ } catch ( error ) {
92+ expect ( error ) . to . be . instanceOf ( TypeError )
93+ done ( )
94+ }
95+ } )
7996} )
Original file line number Diff line number Diff line change 77 * of a Microcosm.
88 */
99
10- function PluginFactory ( config , options , app ) {
10+ function PluginFactory ( config , options , app ) {
1111 return Object . assign ( { app, options } , config )
1212}
1313
14+ function checkPlugin ( plugin ) {
15+ if ( process . env . NODE_ENV === 'development' && 'register' in plugin && typeof plugin . register !== 'function' ) {
16+ throw TypeError ( 'Expected register property of plugin to be a function, instead got ' + plugin . register )
17+ }
18+ }
19+
1420function installPlugin ( next , plugin ) {
21+ checkPlugin ( plugin )
22+
1523 return function ( error ) {
1624 // Halt execution of all future plugin installation if there is an error
1725 if ( error ) {
You can’t perform that action at this time.
0 commit comments