@@ -200,17 +200,17 @@ moduleFor('Components test: sendAction', class extends RenderingTest {
200200moduleFor ( 'Components test: sendAction to a controller' , class extends ApplicationTest {
201201
202202 [ '@test sendAction should trigger an action on the parent component\'s controller if it exists' ] ( assert ) {
203- assert . expect ( 7 ) ;
203+ assert . expect ( 10 ) ;
204204
205205 let component ;
206206
207207 this . router . map ( function ( ) {
208+ this . route ( 'withController' ) ;
209+ this . route ( 'withoutController' ) ;
208210 this . route ( 'withNestedController' , function ( ) {
209211 this . route ( 'nestedWithController' ) ;
210212 this . route ( 'nestedWithoutController' ) ;
211213 } ) ;
212- this . route ( 'withController' ) ;
213- this . route ( 'withoutController' ) ;
214214 } ) ;
215215
216216 this . registerComponent ( 'foo-bar' , {
@@ -222,52 +222,64 @@ moduleFor('Components test: sendAction to a controller', class extends Applicati
222222 } )
223223 } ) ;
224224
225- this . registerTemplate ( 'withNestedController' , '{{foo-bar poke="poke"}}{{outlet}}' ) ;
226- this . registerTemplate ( 'withController' , '{{foo-bar poke="poke"}}' ) ;
227- this . registerTemplate ( 'withoutController' , '{{foo-bar poke="poke"}}' ) ;
228- this . registerTemplate ( 'withNestedController.nestedWithController' , '{{foo-bar poke="poke"}}' ) ;
229- this . registerTemplate ( 'withNestedController.nestedWithoutController' , '{{foo-bar poke="poke"}}' ) ;
230-
225+ this . registerRoute ( 'withController' , Route ) ;
231226 this . registerController ( 'withController' , Controller . extend ( {
232227 send ( actionName , actionContext ) {
233228 assert . equal ( actionName , 'poke' , 'send() method was invoked from a top level controller' ) ;
234229 assert . equal ( actionContext , 'top' , 'action arguments were passed into the top level controller' ) ;
235230 }
236231 } ) ) ;
232+ this . registerTemplate ( 'withController' , '{{foo-bar poke="poke"}}' ) ;
233+
234+ this . registerRoute ( 'withoutController' , Route . extend ( {
235+ actions : {
236+ poke ( actionContext ) {
237+ assert . ok ( true , 'Unhandled action sent to route' ) ;
238+ assert . equal ( actionContext , 'top no controller' ) ;
239+ }
240+ }
241+ } ) ) ;
242+ this . registerTemplate ( 'withoutController' , '{{foo-bar poke="poke"}}' ) ;
237243
244+ this . registerRoute ( 'withNestedController' , Route . extend ( {
245+ actions : {
246+ poke ( actionContext ) {
247+ assert . ok ( true , 'Unhandled action sent to route' ) ;
248+ assert . equal ( actionContext , 'top with nested no controller' ) ;
249+ }
250+ }
251+ } ) ) ;
252+ this . registerTemplate ( 'withNestedController' , '{{foo-bar poke="poke"}}{{outlet}}' ) ;
253+
254+ this . registerRoute ( 'withNestedController.nestedWithController' , Route ) ;
238255 this . registerController ( 'withNestedControllerNestedWithController' , Controller . extend ( {
239256 send ( actionName , actionContext ) {
240257 assert . equal ( actionName , 'poke' , 'send() method was invoked from a nested controller' ) ;
241258 assert . equal ( actionContext , 'nested' , 'action arguments were passed into the nested controller' ) ;
242259 }
243260 } ) ) ;
261+ this . registerTemplate ( 'withNestedController.nestedWithController' , '{{foo-bar poke="poke"}}' ) ;
244262
245- this . registerRoute ( 'withController' , Route ) ;
246- this . registerRoute ( 'withNestedController' , Route ) ;
247- this . registerRoute ( 'withNestedController.nestedWithController' , Route ) ;
248- this . registerRoute ( 'withNestedController.nestedWithOutController' , Route ) ;
249- this . registerRoute ( 'withoutController' , Route ) ;
250-
251- function expectSendActionToThrow ( ) {
252- let fn = ( ) => component . sendAction ( 'poke' ) ;
253- if ( EmberDev && EmberDev . runningProdBuild ) {
254- expectAssertion ( fn ) ;
255- } else {
256- assert . throws ( fn ) ;
263+ this . registerRoute ( 'withNestedController.nestedWithoutController' , Route . extend ( {
264+ actions : {
265+ poke ( actionContext ) {
266+ assert . ok ( true , 'Unhandled action sent to route' ) ;
267+ assert . equal ( actionContext , 'nested no controller' ) ;
268+ }
257269 }
258- }
270+ } ) ) ;
271+ this . registerTemplate ( 'withNestedController.nestedWithoutController' , '{{foo-bar poke="poke"}}' ) ;
259272
260273 return this . visit ( '/withController' )
261274 . then ( ( ) => component . sendAction ( 'poke' , 'top' ) )
262- . then ( ( ) => this . visit ( 'withoutController' ) )
263- . then ( expectSendActionToThrow )
264- // withNestedController.index does not have a controller specified, so it should throw
275+ . then ( ( ) => this . visit ( '/withoutController' ) )
276+ . then ( ( ) => component . sendAction ( 'poke' , 'top no controller' ) )
265277 . then ( ( ) => this . visit ( '/withNestedController' ) )
266- . then ( expectSendActionToThrow )
278+ . then ( ( ) => component . sendAction ( 'poke' , 'top with nested no controller' ) )
267279 . then ( ( ) => this . visit ( '/withNestedController/nestedWithController' ) )
268280 . then ( ( ) => component . sendAction ( 'poke' , 'nested' ) )
269281 . then ( ( ) => this . visit ( '/withNestedController/nestedWithoutController' ) )
270- . then ( expectSendActionToThrow ) ;
282+ . then ( ( ) => component . sendAction ( 'poke' , 'nested no controller' ) ) ;
271283 }
272284
273285 [ '@test sendAction should not trigger an action an outlet\'s controller if a parent component handles it' ] ( assert ) {
@@ -310,7 +322,7 @@ moduleFor('Components test: sendAction to a controller', class extends Applicati
310322moduleFor ( 'Components test: sendAction of a closure action' , class extends RenderingTest {
311323
312324 [ '@test action should be called' ] ( assert ) {
313- this . assert . expect ( 1 ) ;
325+ assert . expect ( 1 ) ;
314326 let component ;
315327
316328 this . registerComponent ( 'inner-component' , {
@@ -400,8 +412,8 @@ moduleFor('Components test: send', class extends RenderingTest {
400412
401413 this . runTask ( ( ) => component . send ( 'foo' , 'bar' ) ) ;
402414
403- expectAssertion ( function ( ) {
404- component . send ( 'baz' , 'bar' ) ;
415+ expectAssertion ( ( ) => {
416+ return component . send ( 'baz' , 'bar' ) ;
405417 } , / h a d n o a c t i o n h a n d l e r f o r : b a z / ) ;
406418 }
407419
0 commit comments