@@ -38,13 +38,54 @@ function createComponent(project, properties) {
3838 projects : Ember . Object . create ( { current : project } ) ,
3939 initialPorts : Ember . A ( ) ,
4040 schedulePortPreflight ( ) { } ,
41- sendAction ( ) { } ,
4241 } , properties || { } ) , 'component' ) ;
4342 } ) ;
4443
4544 return component ;
4645}
4746
47+ test ( 'closure callbacks are invoked directly and missing optional callbacks are ignored' , function ( assert ) {
48+ let changedRows ;
49+ let changedSpecs ;
50+ let preflightState ;
51+ let component = createComponent ( null , {
52+ changed ( value ) {
53+ changedRows = value ;
54+ } ,
55+ changedStr ( value ) {
56+ changedSpecs = value ;
57+ } ,
58+ preflightChanged ( value ) {
59+ preflightState = value ;
60+ } ,
61+ sendAction ( ) {
62+ assert . ok ( false , 'closure callbacks must not be routed through legacy sendAction' ) ;
63+ } ,
64+ } ) ;
65+ let row = portRow ( '8080' , '80' ) ;
66+
67+ Ember . run ( ( ) => component . set ( 'portsArray' , Ember . A ( [ row ] ) ) ) ;
68+ component . portsArrayDidChange ( ) ;
69+ component . applyPreflightState ( 'available' , [ ] , null , {
70+ eligibleHostCount : 1 ,
71+ availableHostCount : 1 ,
72+ } ) ;
73+
74+ assert . strictEqual ( changedRows , component . get ( 'portsArray' ) , 'passes the live row array' ) ;
75+ assert . deepEqual ( changedSpecs , [ '8080:80/tcp' ] , 'passes the serialized port specs' ) ;
76+ assert . equal ( preflightState . status , 'available' , 'passes the preflight result' ) ;
77+
78+ Ember . run ( ( ) => component . setProperties ( {
79+ changed : null ,
80+ changedStr : null ,
81+ preflightChanged : null ,
82+ } ) ) ;
83+ component . portsArrayDidChange ( ) ;
84+ component . applyPreflightState ( 'available' , [ ] , null , null ) ;
85+ assert . ok ( true , 'missing optional callbacks do not throw' ) ;
86+ destroyOwned ( component ) ;
87+ } ) ;
88+
4889function projectWithAction ( callback ) {
4990 return Ember . Object . create ( {
5091 actionLinks : { portpreflight : '/v2-beta/projects/1a5?action=portpreflight' } ,
0 commit comments