@@ -368,10 +368,10 @@ define(function (require, exports, module) {
368
368
var promise = _testWindow . executeCommand ( _testWindow . brackets . test . Commands . FILE_CLOSE_ALL ) ;
369
369
waitsForDone ( promise , "Close all open files in working set" ) ;
370
370
371
- var $dlg = _testWindow . $ ( ".modal.instance" ) ;
372
- if ( $dlg . length ) {
373
- clickDialogButton ( "dontsave" ) ;
374
- }
371
+ _testWindow . brackets . test . Dialogs . cancelModalDialogIfOpen (
372
+ _testWindow . brackets . test . DefaultDialogs . DIALOG_ID_SAVE_CLOSE ,
373
+ _testWindow . brackets . test . DefaultDialogs . DIALOG_BTN_DONTSAVE
374
+ ) ;
375
375
} ) ;
376
376
} ;
377
377
} ) ;
@@ -1036,6 +1036,22 @@ define(function (require, exports, module) {
1036
1036
_addSuiteFunction ( "afterLast" , func ) ;
1037
1037
} ;
1038
1038
1039
+ /**
1040
+ * @private
1041
+ * Returns an array with the parent suites of the current spec with the top most suite last
1042
+ * @return {Array.<jasmine.Suite> }
1043
+ */
1044
+ function _getParentSuites ( ) {
1045
+ var suite = jasmine . getEnv ( ) . currentSpec . suite ,
1046
+ suites = [ ] ;
1047
+
1048
+ while ( suite ) {
1049
+ suites . push ( suite ) ;
1050
+ suite = suite . parentSuite ;
1051
+ }
1052
+ return suites ;
1053
+ }
1054
+
1039
1055
/**
1040
1056
* @private
1041
1057
* Calls each function in the given array of functions
@@ -1049,30 +1065,29 @@ define(function (require, exports, module) {
1049
1065
}
1050
1066
1051
1067
/**
1052
- * Calls the before first functions for the parent suites of the current spec when is the first spec of each suite.
1068
+ * Calls the before first functions for the parent suites of the current spec when is the first spec of the suite.
1053
1069
*/
1054
1070
function runBeforeFirst ( ) {
1055
- var suite = jasmine . getEnv ( ) . currentSpec . suite ;
1071
+ var suites = _getParentSuites ( ) . reverse ( ) ;
1056
1072
1057
- // Iterate throught all the parent suites of the current spec
1058
- while ( suite ) {
1073
+ // Iterate through all the parent suites of the current spec
1074
+ suites . forEach ( function ( suite ) {
1059
1075
// If we have functions for this suite and it was never called, initialize the spec counter
1060
1076
if ( _testSuites [ suite . id ] && _testSuites [ suite . id ] . specCounter === null ) {
1061
1077
_callFunctions ( _testSuites [ suite . id ] . beforeFirst ) ;
1062
1078
_testSuites [ suite . id ] . specCounter = countSpecs ( suite ) ;
1063
1079
}
1064
- suite = suite . parentSuite ;
1065
- }
1080
+ } ) ;
1066
1081
}
1067
1082
1068
1083
/**
1069
- * Calls the after last functions for the parent suites of the current spec when is the last spec of each suite.
1084
+ * Calls the after last functions for the parent suites of the current spec when is the last spec of the suite.
1070
1085
*/
1071
1086
function runAfterLast ( ) {
1072
- var suite = jasmine . getEnv ( ) . currentSpec . suite ;
1087
+ var suites = _getParentSuites ( ) ;
1073
1088
1074
1089
// Iterate throught all the parent suites of the current spec
1075
- while ( suite ) {
1090
+ suites . forEach ( function ( suite ) {
1076
1091
// If we have functions for this suite, reduce the spec counter
1077
1092
if ( _testSuites [ suite . id ] && _testSuites [ suite . id ] . specCounter > 0 ) {
1078
1093
_testSuites [ suite . id ] . specCounter -- ;
@@ -1083,8 +1098,7 @@ define(function (require, exports, module) {
1083
1098
delete _testSuites [ suite . id ] ;
1084
1099
}
1085
1100
}
1086
- suite = suite . parentSuite ;
1087
- }
1101
+ } ) ;
1088
1102
}
1089
1103
1090
1104
0 commit comments