jasmine-core 3.2.1 → 3.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 820a13bd1d42382b3bee6d2f0614453a9f27a2941765b317dc4aa72f8fe712b4
4
- data.tar.gz: 22a497c2dd1f59e2900d95d29436c18347914aae8394edccd554bd53b15a7413
3
+ metadata.gz: 4408443a5a610c1e7535cb6bcaa3a316290adde9aec1cbfc4cf6ae0dc6085937
4
+ data.tar.gz: 73da51b15bc89f5e45e3fb91c3186f78631954e5dcb7a6a272be5e1c3b9a0ea3
5
5
  SHA512:
6
- metadata.gz: bc2382ef555009b94121db01e9135f7cf298caa069036b2480207c8a13890bb013fdbbe6c291e1dbc124971fab4c8e76dbd3ed591e71ecfed7b81d3875c9824b
7
- data.tar.gz: be6038248103c017767917e75b80f4cf1706350c852c43bc8b15a346b1ade1b5ab6262f40bb6be10c522feaa39f16ee5b98305be3d6ab906ca602d72820d2032
6
+ metadata.gz: 5f532a3591a0f28d992471eb9fe75256fe0afa0e4ddc7a1abb3efe22e8ab455755c1acb25371b530d26c5f636105f0f3feb54df49e4c212b9bb2906c0c3e6859
7
+ data.tar.gz: e37bcb79937ccd115390dd99027cc8ebf773c1a648319a3bee4dc82506590dcab2bacc5b74a225bd96c0f3a623ea156d820d61a8f683375e006150d95e38cbb7
@@ -73,24 +73,21 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
73
73
 
74
74
  var filterSpecs = !!queryString.getParam("spec");
75
75
 
76
- var stoppingOnSpecFailure = queryString.getParam("failFast");
77
- env.stopOnSpecFailure(stoppingOnSpecFailure);
78
-
79
- var throwingExpectationFailures = queryString.getParam("throwFailures");
80
- env.throwOnExpectationFailure(throwingExpectationFailures);
81
-
82
- var hideDisabled = queryString.getParam("hideDisabled");
83
- env.hideDisabled(hideDisabled);
76
+ var config = {
77
+ failFast: queryString.getParam("failFast"),
78
+ oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
79
+ hideDisabled: queryString.getParam("hideDisabled")
80
+ };
84
81
 
85
82
  var random = queryString.getParam("random");
86
83
 
87
84
  if (random !== undefined && random !== "") {
88
- env.randomizeTests(random);
85
+ config.random = random;
89
86
  }
90
87
 
91
88
  var seed = queryString.getParam("seed");
92
89
  if (seed) {
93
- env.seed(seed);
90
+ config.seed = seed;
94
91
  }
95
92
 
96
93
  /**
@@ -121,10 +118,12 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
121
118
  filterString: function() { return queryString.getParam("spec"); }
122
119
  });
123
120
 
124
- env.specFilter = function(spec) {
121
+ config.specFilter = function(spec) {
125
122
  return specFilter.matches(spec.getFullName());
126
123
  };
127
124
 
125
+ env.configure(config);
126
+
128
127
  /**
129
128
  * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
130
129
  */
@@ -51,24 +51,21 @@
51
51
 
52
52
  var filterSpecs = !!queryString.getParam("spec");
53
53
 
54
- var stoppingOnSpecFailure = queryString.getParam("failFast");
55
- env.stopOnSpecFailure(stoppingOnSpecFailure);
56
-
57
- var throwingExpectationFailures = queryString.getParam("throwFailures");
58
- env.throwOnExpectationFailure(throwingExpectationFailures);
59
-
60
- var hideDisabled = queryString.getParam("hideDisabled");
61
- env.hideDisabled(hideDisabled);
54
+ var config = {
55
+ failFast: queryString.getParam("failFast"),
56
+ oneFailurePerSpec: queryString.getParam("oneFailurePerSpec"),
57
+ hideDisabled: queryString.getParam("hideDisabled")
58
+ };
62
59
 
63
60
  var random = queryString.getParam("random");
64
61
 
65
62
  if (random !== undefined && random !== "") {
66
- env.randomizeTests(random);
63
+ config.random = random;
67
64
  }
68
65
 
69
66
  var seed = queryString.getParam("seed");
70
67
  if (seed) {
71
- env.seed(seed);
68
+ config.seed = seed;
72
69
  }
73
70
 
74
71
  /**
@@ -99,10 +96,12 @@
99
96
  filterString: function() { return queryString.getParam("spec"); }
100
97
  });
101
98
 
102
- env.specFilter = function(spec) {
99
+ config.specFilter = function(spec) {
103
100
  return specFilter.matches(spec.getFullName());
104
101
  };
105
102
 
103
+ env.configure(config);
104
+
106
105
  /**
107
106
  * Setting up timing functions to be able to be overridden. Certain browsers (Safari, IE 8, phantomjs) require this hack.
108
107
  */
@@ -80,7 +80,7 @@ jasmineRequire.HtmlReporter = function(j$) {
80
80
 
81
81
 
82
82
  function HtmlReporter(options) {
83
- var env = options.env || {},
83
+ var config = function() { return (options.env && options.env.configuration()) || {}; },
84
84
  getContainer = options.getContainer,
85
85
  createElement = options.createElement,
86
86
  createTextNode = options.createTextNode,
@@ -167,9 +167,9 @@ jasmineRequire.HtmlReporter = function(j$) {
167
167
 
168
168
  this.resultStatus = function(status) {
169
169
  if(status === 'excluded') {
170
- return env.hidingDisabled() ? 'jasmine-excluded-no-display' : 'jasmine-excluded';
171
- }
172
- return 'jasmine-' + status;
170
+ return config().hideDisabled ? 'jasmine-excluded-no-display' : 'jasmine-excluded';
171
+ }
172
+ return 'jasmine-' + status;
173
173
  };
174
174
 
175
175
  this.jasmineDone = function(doneResult) {
@@ -179,7 +179,7 @@ jasmineRequire.HtmlReporter = function(j$) {
179
179
  var i;
180
180
  alert.appendChild(createDom('span', {className: 'jasmine-duration'}, 'finished in ' + timer.elapsed() / 1000 + 's'));
181
181
 
182
- banner.appendChild(optionsMenu(env));
182
+ banner.appendChild(optionsMenu(config()));
183
183
 
184
184
  if (stateBuilder.specsExecuted < totalSpecsDefined) {
185
185
  var skippedMessage = 'Ran ' + stateBuilder.specsExecuted + ' of ' + totalSpecsDefined + ' specs - run all';
@@ -339,7 +339,7 @@ jasmineRequire.HtmlReporter = function(j$) {
339
339
  }
340
340
  }
341
341
 
342
- function optionsMenu(env) {
342
+ function optionsMenu(config) {
343
343
  var optionsMenuDom = createDom('div', { className: 'jasmine-run-options' },
344
344
  createDom('span', { className: 'jasmine-trigger' }, 'Options'),
345
345
  createDom('div', { className: 'jasmine-payload' },
@@ -375,27 +375,27 @@ jasmineRequire.HtmlReporter = function(j$) {
375
375
  );
376
376
 
377
377
  var failFastCheckbox = optionsMenuDom.querySelector('#jasmine-fail-fast');
378
- failFastCheckbox.checked = env.stoppingOnSpecFailure();
378
+ failFastCheckbox.checked = config.failFast;
379
379
  failFastCheckbox.onclick = function() {
380
- navigateWithNewParam('failFast', !env.stoppingOnSpecFailure());
380
+ navigateWithNewParam('failFast', !config.failFast);
381
381
  };
382
382
 
383
383
  var throwCheckbox = optionsMenuDom.querySelector('#jasmine-throw-failures');
384
- throwCheckbox.checked = env.throwingExpectationFailures();
384
+ throwCheckbox.checked = config.oneFailurePerSpec;
385
385
  throwCheckbox.onclick = function() {
386
- navigateWithNewParam('throwFailures', !env.throwingExpectationFailures());
386
+ navigateWithNewParam('throwFailures', !config.oneFailurePerSpec);
387
387
  };
388
388
 
389
389
  var randomCheckbox = optionsMenuDom.querySelector('#jasmine-random-order');
390
- randomCheckbox.checked = env.randomTests();
390
+ randomCheckbox.checked = config.random;
391
391
  randomCheckbox.onclick = function() {
392
- navigateWithNewParam('random', !env.randomTests());
392
+ navigateWithNewParam('random', !config.random);
393
393
  };
394
394
 
395
395
  var hideDisabled = optionsMenuDom.querySelector('#jasmine-hide-disabled');
396
- hideDisabled.checked = env.hidingDisabled();
396
+ hideDisabled.checked = config.hideDisabled;
397
397
  hideDisabled.onclick = function() {
398
- navigateWithNewParam('hideDisabled', !env.hidingDisabled());
398
+ navigateWithNewParam('hideDisabled', !config.hideDisabled);
399
399
  };
400
400
 
401
401
  var optionsTrigger = optionsMenuDom.querySelector('.jasmine-trigger'),
@@ -1,3 +1,4 @@
1
+ @charset "UTF-8";
1
2
  body { overflow-y: scroll; }
2
3
 
3
4
  .jasmine_html-reporter { background-color: #eee; padding: 5px; margin: -8px; font-size: 11px; font-family: Monaco, "Lucida Console", monospace; line-height: 14px; color: #333; }
@@ -15,16 +16,16 @@ body { overflow-y: scroll; }
15
16
  .jasmine_html-reporter .jasmine-symbol-summary { overflow: hidden; *zoom: 1; margin: 14px 0; }
16
17
  .jasmine_html-reporter .jasmine-symbol-summary li { display: inline-block; height: 10px; width: 14px; font-size: 16px; }
17
18
  .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed { font-size: 14px; }
18
- .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed:before { color: #007069; content: "\02022"; }
19
+ .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-passed:before { color: #007069; content: ""; }
19
20
  .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed { line-height: 9px; }
20
- .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed:before { color: #ca3a11; content: "\d7"; font-weight: bold; margin-left: -1px; }
21
+ .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-failed:before { color: #ca3a11; content: "×"; font-weight: bold; margin-left: -1px; }
21
22
  .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded { font-size: 14px; }
22
- .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded:before { color: #bababa; content: "\02022"; }
23
+ .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded:before { color: #bababa; content: ""; }
23
24
  .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-excluded-no-display { font-size: 14px; display: none; }
24
25
  .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending { line-height: 17px; }
25
26
  .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-pending:before { color: #ba9d37; content: "*"; }
26
27
  .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty { font-size: 14px; }
27
- .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty:before { color: #ba9d37; content: "\02022"; }
28
+ .jasmine_html-reporter .jasmine-symbol-summary li.jasmine-empty:before { color: #ba9d37; content: ""; }
28
29
  .jasmine_html-reporter .jasmine-run-options { float: right; margin-right: 5px; border: 1px solid #8a4182; color: #8a4182; position: relative; line-height: 20px; }
29
30
  .jasmine_html-reporter .jasmine-run-options .jasmine-trigger { cursor: pointer; padding: 8px 16px; }
30
31
  .jasmine_html-reporter .jasmine-run-options .jasmine-payload { position: absolute; display: none; right: -1px; border: 1px solid #8a4182; background-color: #eee; white-space: nowrap; padding: 4px 8px; }
@@ -49,6 +50,11 @@ body { overflow-y: scroll; }
49
50
  .jasmine_html-reporter .jasmine-summary li.jasmine-empty a { color: #ba9d37; }
50
51
  .jasmine_html-reporter .jasmine-summary li.jasmine-pending a { color: #ba9d37; }
51
52
  .jasmine_html-reporter .jasmine-summary li.jasmine-excluded a { color: #bababa; }
53
+ .jasmine_html-reporter .jasmine-specs li.jasmine-passed a:before { content: "• "; }
54
+ .jasmine_html-reporter .jasmine-specs li.jasmine-failed a:before { content: "× "; }
55
+ .jasmine_html-reporter .jasmine-specs li.jasmine-empty a:before { content: "* "; }
56
+ .jasmine_html-reporter .jasmine-specs li.jasmine-pending a:before { content: "• "; }
57
+ .jasmine_html-reporter .jasmine-specs li.jasmine-excluded a:before { content: "• "; }
52
58
  .jasmine_html-reporter .jasmine-description + .jasmine-suite { margin-top: 0; }
53
59
  .jasmine_html-reporter .jasmine-suite { margin-top: 14px; }
54
60
  .jasmine_html-reporter .jasmine-suite a { color: #333; }
@@ -59,8 +59,9 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
59
59
  j$.Env = jRequire.Env(j$);
60
60
  j$.StackTrace = jRequire.StackTrace(j$);
61
61
  j$.ExceptionFormatter = jRequire.ExceptionFormatter(j$);
62
- j$.Expectation = jRequire.Expectation();
63
- j$.AsyncExpectation = jRequire.AsyncExpectation(j$);
62
+ j$.ExpectationFilterChain = jRequire.ExpectationFilterChain();
63
+ j$.Expector = jRequire.Expector(j$);
64
+ j$.Expectation = jRequire.Expectation(j$);
64
65
  j$.buildExpectationResult = jRequire.buildExpectationResult();
65
66
  j$.JsApiReporter = jRequire.JsApiReporter();
66
67
  j$.matchersUtil = jRequire.matchersUtil(j$);
@@ -93,6 +94,7 @@ var getJasmineRequireObj = (function (jasmineGlobal) {
93
94
  j$.NotEmpty = jRequire.NotEmpty(j$);
94
95
 
95
96
  j$.matchers = jRequire.requireMatchers(jRequire, j$);
97
+ j$.asyncMatchers = jRequire.requireAsyncMatchers(jRequire, j$);
96
98
 
97
99
  return j$;
98
100
  };
@@ -261,7 +263,11 @@ getJasmineRequireObj().base = function(j$, jasmineGlobal) {
261
263
  };
262
264
 
263
265
  j$.isPromise = function(obj) {
264
- return typeof jasmineGlobal.Promise !== 'undefined' && obj && obj.constructor === jasmineGlobal.Promise;
266
+ return typeof jasmineGlobal.Promise !== 'undefined' && !!obj && obj.constructor === jasmineGlobal.Promise;
267
+ };
268
+
269
+ j$.isPromiseLike = function(obj) {
270
+ return !!obj && j$.isFunction_(obj.then);
265
271
  };
266
272
 
267
273
  j$.fnNameFor = function(func) {
@@ -794,14 +800,62 @@ getJasmineRequireObj().Env = function(j$) {
794
800
  var currentSpec = null;
795
801
  var currentlyExecutingSuites = [];
796
802
  var currentDeclarationSuite = null;
797
- var throwOnExpectationFailure = false;
798
- var stopOnSpecFailure = false;
799
- var random = true;
800
- var hidingDisabled = false;
801
- var seed = null;
802
- var handlingLoadErrors = true;
803
803
  var hasFailures = false;
804
804
 
805
+ /**
806
+ * This represents the available options to configure Jasmine.
807
+ * Options that are not provided will use their default values
808
+ * @interface Configuration
809
+ */
810
+ var config = {
811
+ /**
812
+ * Whether to randomize spec execution order
813
+ * @name Configuration#random
814
+ * @type Boolean
815
+ * @default true
816
+ */
817
+ random: true,
818
+ /**
819
+ * Seed to use as the basis of randomization.
820
+ * Null causes the seed to be determined randomly at the start of execution.
821
+ * @name Configuration#seed
822
+ * @type function
823
+ * @default null
824
+ */
825
+ seed: null,
826
+ /**
827
+ * Whether to stop execution of the suite after the first spec failure
828
+ * @name Configuration#failFast
829
+ * @type Boolean
830
+ * @default false
831
+ */
832
+ failFast: false,
833
+ /**
834
+ * Whether to cause specs to only have one expectation failure.
835
+ * @name Configuration#oneFailurePerSpec
836
+ * @type Boolean
837
+ * @default false
838
+ */
839
+ oneFailurePerSpec: false,
840
+ /**
841
+ * Function to use to filter specs
842
+ * @name Configuration#specFilter
843
+ * @type function
844
+ * @default true
845
+ */
846
+ specFilter: function() {
847
+ return true;
848
+ },
849
+ /**
850
+ * Whether or not reporters should hide disabled specs from their output.
851
+ * Currently only supported by Jasmine's HTMLReporter
852
+ * @name Configuration#hideDisabled
853
+ * @type Boolean
854
+ * @default false
855
+ */
856
+ hideDisabled: false
857
+ };
858
+
805
859
  var currentSuite = function() {
806
860
  return currentlyExecutingSuites[currentlyExecutingSuites.length - 1];
807
861
  };
@@ -834,10 +888,63 @@ getJasmineRequireObj().Env = function(j$) {
834
888
  });
835
889
  }
836
890
 
837
- this.specFilter = function() {
838
- return true;
891
+ /**
892
+ * Configure your jasmine environment
893
+ * @name Env#configure
894
+ * @argument {Configuration} configuration
895
+ * @function
896
+ */
897
+ this.configure = function(configuration) {
898
+ if (configuration.specFilter) {
899
+ config.specFilter = configuration.specFilter;
900
+ }
901
+
902
+ if (configuration.hasOwnProperty('random')) {
903
+ config.random = !!configuration.random;
904
+ }
905
+
906
+ if (configuration.hasOwnProperty('seed')) {
907
+ config.seed = configuration.seed;
908
+ }
909
+
910
+ if (configuration.hasOwnProperty('failFast')) {
911
+ config.failFast = configuration.failFast;
912
+ }
913
+
914
+ if (configuration.hasOwnProperty('oneFailurePerSpec')) {
915
+ config.oneFailurePerSpec = configuration.oneFailurePerSpec;
916
+ }
917
+
918
+ if (configuration.hasOwnProperty('hideDisabled')) {
919
+ config.hideDisabled = configuration.hideDisabled;
920
+ }
921
+ };
922
+
923
+ /**
924
+ * Get the current configuration for your jasmine environment
925
+ * @name Env#configuration
926
+ * @function
927
+ * @returns {Configuration}
928
+ */
929
+ this.configuration = function() {
930
+ var result = {};
931
+ for (var property in config) {
932
+ result[property] = config[property];
933
+ }
934
+ return result;
839
935
  };
840
936
 
937
+ Object.defineProperty(this, 'specFilter', {
938
+ get: function() {
939
+ self.deprecated('Getting specFilter directly from Env is deprecated, please check the specFilter option from `configuration`');
940
+ return config.specFilter;
941
+ },
942
+ set: function(val) {
943
+ self.deprecated('Setting specFilter directly on Env is deprecated, please use the specFilter option in `configure`');
944
+ config.specFilter = val;
945
+ }
946
+ });
947
+
841
948
  this.addSpyStrategy = function(name, fn) {
842
949
  if(!currentRunnable()) {
843
950
  throw new Error('Custom spy strategies must be added in a before function or a spec');
@@ -863,6 +970,7 @@ getJasmineRequireObj().Env = function(j$) {
863
970
  };
864
971
 
865
972
  j$.Expectation.addCoreMatchers(j$.matchers);
973
+ j$.Expectation.addAsyncCoreMatchers(j$.asyncMatchers);
866
974
 
867
975
  var nextSpecId = 0;
868
976
  var getNextSpecId = function() {
@@ -875,7 +983,7 @@ getJasmineRequireObj().Env = function(j$) {
875
983
  };
876
984
 
877
985
  var expectationFactory = function(actual, spec) {
878
- return j$.Expectation.Factory({
986
+ return j$.Expectation.factory({
879
987
  util: j$.matchersUtil,
880
988
  customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
881
989
  customMatchers: runnableResources[spec.id].customMatchers,
@@ -889,7 +997,7 @@ getJasmineRequireObj().Env = function(j$) {
889
997
  };
890
998
 
891
999
  var asyncExpectationFactory = function(actual, spec) {
892
- return j$.AsyncExpectation.factory({
1000
+ return j$.Expectation.asyncFactory({
893
1001
  util: j$.matchersUtil,
894
1002
  customEqualityTesters: runnableResources[spec.id].customEqualityTesters,
895
1003
  actual: actual,
@@ -965,13 +1073,16 @@ getJasmineRequireObj().Env = function(j$) {
965
1073
  * @name Env#throwOnExpectationFailure
966
1074
  * @function
967
1075
  * @param {Boolean} value Whether to throw when a expectation fails
1076
+ * @deprecated Use the `oneFailurePerSpec` option with {@link Env#configure}
968
1077
  */
969
1078
  this.throwOnExpectationFailure = function(value) {
970
- throwOnExpectationFailure = !!value;
1079
+ this.deprecated('Setting throwOnExpectationFailure directly on Env is deprecated, please use the oneFailurePerSpec option in `configure`');
1080
+ this.configure({oneFailurePerSpec: !!value});
971
1081
  };
972
1082
 
973
1083
  this.throwingExpectationFailures = function() {
974
- return throwOnExpectationFailure;
1084
+ this.deprecated('Getting throwingExpectationFailures directly from Env is deprecated, please check the oneFailurePerSpec option from `configuration`');
1085
+ return config.oneFailurePerSpec;
975
1086
  };
976
1087
 
977
1088
  /**
@@ -979,13 +1090,16 @@ getJasmineRequireObj().Env = function(j$) {
979
1090
  * @name Env#stopOnSpecFailure
980
1091
  * @function
981
1092
  * @param {Boolean} value Whether to stop suite execution when a spec fails
1093
+ * @deprecated Use the `failFast` option with {@link Env#configure}
982
1094
  */
983
1095
  this.stopOnSpecFailure = function(value) {
984
- stopOnSpecFailure = !!value;
1096
+ this.deprecated('Setting stopOnSpecFailure directly is deprecated, please use the failFast option in `configure`');
1097
+ this.configure({failFast: !!value});
985
1098
  };
986
1099
 
987
1100
  this.stoppingOnSpecFailure = function() {
988
- return stopOnSpecFailure;
1101
+ this.deprecated('Getting stoppingOnSpecFailure directly from Env is deprecated, please check the failFast option from `configuration`');
1102
+ return config.failFast;
989
1103
  };
990
1104
 
991
1105
  /**
@@ -993,13 +1107,16 @@ getJasmineRequireObj().Env = function(j$) {
993
1107
  * @name Env#randomizeTests
994
1108
  * @function
995
1109
  * @param {Boolean} value Whether to randomize execution order
1110
+ * @deprecated Use the `random` option with {@link Env#configure}
996
1111
  */
997
1112
  this.randomizeTests = function(value) {
998
- random = !!value;
1113
+ this.deprecated('Setting randomizeTests directly is deprecated, please use the random option in `configure`');
1114
+ config.random = !!value;
999
1115
  };
1000
1116
 
1001
1117
  this.randomTests = function() {
1002
- return random;
1118
+ this.deprecated('Getting randomTests directly from Env is deprecated, please check the random option from `configuration`');
1119
+ return config.random;
1003
1120
  };
1004
1121
 
1005
1122
  /**
@@ -1007,16 +1124,19 @@ getJasmineRequireObj().Env = function(j$) {
1007
1124
  * @name Env#seed
1008
1125
  * @function
1009
1126
  * @param {Number} value The seed value
1127
+ * @deprecated Use the `seed` option with {@link Env#configure}
1010
1128
  */
1011
1129
  this.seed = function(value) {
1130
+ this.deprecated('Setting seed directly is deprecated, please use the seed option in `configure`');
1012
1131
  if (value) {
1013
- seed = value;
1132
+ config.seed = value;
1014
1133
  }
1015
- return seed;
1134
+ return config.seed;
1016
1135
  };
1017
1136
 
1018
1137
  this.hidingDisabled = function(value) {
1019
- return hidingDisabled;
1138
+ this.deprecated('Getting hidingDisabled directly from Env is deprecated, please check the hideDisabled option from `configuration`');
1139
+ return config.hideDisabled;
1020
1140
  };
1021
1141
 
1022
1142
  /**
@@ -1024,7 +1144,8 @@ getJasmineRequireObj().Env = function(j$) {
1024
1144
  * @function
1025
1145
  */
1026
1146
  this.hideDisabled = function(value) {
1027
- hidingDisabled = !!value;
1147
+ this.deprecated('Setting hideDisabled directly is deprecated, please use the hideDisabled option in `configure`');
1148
+ config.hideDisabled = !!value;
1028
1149
  };
1029
1150
 
1030
1151
  this.deprecated = function(deprecation) {
@@ -1038,9 +1159,9 @@ getJasmineRequireObj().Env = function(j$) {
1038
1159
  var queueRunnerFactory = function(options, args) {
1039
1160
  var failFast = false;
1040
1161
  if (options.isLeaf) {
1041
- failFast = throwOnExpectationFailure;
1162
+ failFast = config.oneFailurePerSpec;
1042
1163
  } else if (!options.isReporter) {
1043
- failFast = stopOnSpecFailure;
1164
+ failFast = config.failFast;
1044
1165
  }
1045
1166
  options.clearStack = options.clearStack || clearStack;
1046
1167
  options.timeout = {setTimeout: realSetTimeout, clearTimeout: realClearTimeout};
@@ -1155,8 +1276,8 @@ getJasmineRequireObj().Env = function(j$) {
1155
1276
  }
1156
1277
 
1157
1278
  var order = new j$.Order({
1158
- random: random,
1159
- seed: seed
1279
+ random: config.random,
1280
+ seed: config.seed
1160
1281
  });
1161
1282
 
1162
1283
  var processor = new j$.TreeProcessor({
@@ -1186,7 +1307,7 @@ getJasmineRequireObj().Env = function(j$) {
1186
1307
  return order.sort(node.children);
1187
1308
  },
1188
1309
  excludeNode: function(spec) {
1189
- return !self.specFilter(spec);
1310
+ return !config.specFilter(spec);
1190
1311
  }
1191
1312
  });
1192
1313
 
@@ -1353,7 +1474,7 @@ getJasmineRequireObj().Env = function(j$) {
1353
1474
  expectationFactory: expectationFactory,
1354
1475
  asyncExpectationFactory: asyncExpectationFactory,
1355
1476
  expectationResultFactory: expectationResultFactory,
1356
- throwOnExpectationFailure: throwOnExpectationFailure
1477
+ throwOnExpectationFailure: config.oneFailurePerSpec
1357
1478
  });
1358
1479
 
1359
1480
  return suite;
@@ -1459,7 +1580,7 @@ getJasmineRequireObj().Env = function(j$) {
1459
1580
  fn: fn,
1460
1581
  timeout: timeout || 0
1461
1582
  },
1462
- throwOnExpectationFailure: throwOnExpectationFailure
1583
+ throwOnExpectationFailure: config.oneFailurePerSpec
1463
1584
  });
1464
1585
 
1465
1586
  return spec;
@@ -1607,7 +1728,7 @@ getJasmineRequireObj().Env = function(j$) {
1607
1728
  error: error && error.message ? error : null
1608
1729
  });
1609
1730
 
1610
- if (self.throwingExpectationFailures()) {
1731
+ if (config.oneFailurePerSpec) {
1611
1732
  throw new Error(message);
1612
1733
  }
1613
1734
  };
@@ -2025,160 +2146,6 @@ getJasmineRequireObj().Truthy = function(j$) {
2025
2146
  return Truthy;
2026
2147
  };
2027
2148
 
2028
- getJasmineRequireObj().AsyncExpectation = function(j$) {
2029
- var promiseForMessage = {
2030
- jasmineToString: function() { return 'a promise'; }
2031
- };
2032
-
2033
- /**
2034
- * Asynchronous matchers.
2035
- * @namespace async-matchers
2036
- */
2037
- function AsyncExpectation(options) {
2038
- var global = options.global || j$.getGlobal();
2039
- this.util = options.util || { buildFailureMessage: function() {} };
2040
- this.customEqualityTesters = options.customEqualityTesters || [];
2041
- this.addExpectationResult = options.addExpectationResult || function(){};
2042
- this.actual = options.actual;
2043
- this.isNot = options.isNot;
2044
-
2045
- if (!global.Promise) {
2046
- throw new Error('expectAsync is unavailable because the environment does not support promises.');
2047
- }
2048
-
2049
- if (!j$.isPromise(this.actual)) {
2050
- throw new Error('Expected expectAsync to be called with a promise.');
2051
- }
2052
-
2053
- ['toBeResolved', 'toBeRejected', 'toBeResolvedTo'].forEach(wrapCompare.bind(this));
2054
- }
2055
-
2056
- function wrapCompare(name) {
2057
- var compare = this[name];
2058
- this[name] = function() {
2059
- var self = this;
2060
- var args = Array.prototype.slice.call(arguments);
2061
- args.unshift(this.actual);
2062
-
2063
- // Capture the call stack here, before we go async, so that it will
2064
- // contain frames that are relevant to the user instead of just parts
2065
- // of Jasmine.
2066
- var errorForStack = j$.util.errorWithStack();
2067
-
2068
- return compare.apply(self, args).then(function(result) {
2069
- var message;
2070
-
2071
- if (self.isNot) {
2072
- result.pass = !result.pass;
2073
- }
2074
-
2075
- args[0] = promiseForMessage;
2076
- message = j$.Expectation.finalizeMessage(self.util, name, self.isNot, args, result);
2077
-
2078
- self.addExpectationResult(result.pass, {
2079
- matcherName: name,
2080
- passed: result.pass,
2081
- message: message,
2082
- error: undefined,
2083
- errorForStack: errorForStack,
2084
- actual: self.actual
2085
- });
2086
- });
2087
- };
2088
- }
2089
-
2090
- /**
2091
- * Expect a promise to be resolved.
2092
- * @function
2093
- * @async
2094
- * @name async-matchers#toBeResolved
2095
- * @example
2096
- * await expectAsync(aPromise).toBeResolved();
2097
- * @example
2098
- * return expectAsync(aPromise).toBeResolved();
2099
- */
2100
- AsyncExpectation.prototype.toBeResolved = function(actual) {
2101
- return actual.then(
2102
- function() { return {pass: true}; },
2103
- function() { return {pass: false}; }
2104
- );
2105
- };
2106
-
2107
- /**
2108
- * Expect a promise to be rejected.
2109
- * @function
2110
- * @async
2111
- * @name async-matchers#toBeRejected
2112
- * @example
2113
- * await expectAsync(aPromise).toBeRejected();
2114
- * @example
2115
- * return expectAsync(aPromise).toBeRejected();
2116
- */
2117
- AsyncExpectation.prototype.toBeRejected = function(actual) {
2118
- return actual.then(
2119
- function() { return {pass: false}; },
2120
- function() { return {pass: true}; }
2121
- );
2122
- };
2123
-
2124
- /**
2125
- * Expect a promise to be resolved to a value equal to the expected, using deep equality comparison.
2126
- * @function
2127
- * @async
2128
- * @name async-matchers#toBeResolvedTo
2129
- * @param {Object} expected - Value that the promise is expected to resolve to
2130
- * @example
2131
- * await expectAsync(aPromise).toBeResolvedTo({prop: 'value'});
2132
- * @example
2133
- * return expectAsync(aPromise).toBeResolvedTo({prop: 'value'});
2134
- */
2135
- AsyncExpectation.prototype.toBeResolvedTo = function(actualPromise, expectedValue) {
2136
- var self = this;
2137
-
2138
- function prefix(passed) {
2139
- return 'Expected a promise ' +
2140
- (passed ? 'not ' : '') +
2141
- 'to be resolved to ' + j$.pp(expectedValue);
2142
- }
2143
-
2144
- return actualPromise.then(
2145
- function(actualValue) {
2146
- if (self.util.equals(actualValue, expectedValue, self.customEqualityTesters)) {
2147
- return {
2148
- pass: true,
2149
- message: prefix(true) + '.'
2150
- };
2151
- } else {
2152
- return {
2153
- pass: false,
2154
- message: prefix(false) + ' but it was resolved to ' + j$.pp(actualValue) + '.'
2155
- };
2156
- }
2157
- },
2158
- function() {
2159
- return {
2160
- pass: false,
2161
- message: prefix(false) + ' but it was rejected.'
2162
- };
2163
- }
2164
- );
2165
- };
2166
-
2167
-
2168
- AsyncExpectation.factory = function(options) {
2169
- var expect = new AsyncExpectation(options);
2170
-
2171
- options = j$.util.clone(options);
2172
- options.isNot = true;
2173
- expect.not = new AsyncExpectation(options);
2174
-
2175
- return expect;
2176
- };
2177
-
2178
-
2179
- return AsyncExpectation;
2180
- };
2181
-
2182
2149
  getJasmineRequireObj().CallTracker = function(j$) {
2183
2150
 
2184
2151
  /**
@@ -2737,6 +2704,8 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
2737
2704
 
2738
2705
  if (error.name && error.message) {
2739
2706
  message += error.name + ': ' + error.message;
2707
+ } else if (error.message) {
2708
+ message += error.message;
2740
2709
  } else {
2741
2710
  message += error.toString() + ' thrown';
2742
2711
  }
@@ -2814,107 +2783,238 @@ getJasmineRequireObj().ExceptionFormatter = function(j$) {
2814
2783
  return ExceptionFormatter;
2815
2784
  };
2816
2785
 
2817
- getJasmineRequireObj().Expectation = function() {
2786
+ getJasmineRequireObj().Expectation = function(j$) {
2787
+ var promiseForMessage = {
2788
+ jasmineToString: function() { return 'a promise'; }
2789
+ };
2818
2790
 
2819
2791
  /**
2820
2792
  * Matchers that come with Jasmine out of the box.
2821
2793
  * @namespace matchers
2822
2794
  */
2823
2795
  function Expectation(options) {
2824
- this.util = options.util || { buildFailureMessage: function() {} };
2825
- this.customEqualityTesters = options.customEqualityTesters || [];
2826
- this.actual = options.actual;
2827
- this.addExpectationResult = options.addExpectationResult || function(){};
2828
- this.isNot = options.isNot;
2796
+ this.expector = new j$.Expector(options);
2829
2797
 
2830
2798
  var customMatchers = options.customMatchers || {};
2831
2799
  for (var matcherName in customMatchers) {
2832
- this[matcherName] = Expectation.prototype.wrapCompare(matcherName, customMatchers[matcherName]);
2800
+ this[matcherName] = wrapSyncCompare(matcherName, customMatchers[matcherName]);
2833
2801
  }
2834
2802
  }
2835
2803
 
2836
- Expectation.prototype.wrapCompare = function(name, matcherFactory) {
2837
- return function() {
2838
- var args = Array.prototype.slice.call(arguments, 0),
2839
- expected = args.slice(0),
2840
- message;
2804
+ /**
2805
+ * Add some context for an {@link expect}
2806
+ * @function
2807
+ * @name matchers#withContext
2808
+ * @param {String} message - Additional context to show when the matcher fails
2809
+ * @return {matchers}
2810
+ */
2811
+ Expectation.prototype.withContext = function withContext(message) {
2812
+ return addFilter(this, new ContextAddingFilter(message));
2813
+ };
2841
2814
 
2842
- args.unshift(this.actual);
2815
+ /**
2816
+ * Invert the matcher following this {@link expect}
2817
+ * @member
2818
+ * @name matchers#not
2819
+ * @type {matchers}
2820
+ * @example
2821
+ * expect(something).not.toBe(true);
2822
+ */
2823
+ Object.defineProperty(Expectation.prototype, 'not', {
2824
+ get: function() {
2825
+ return addFilter(this, syncNegatingFilter);
2826
+ }
2827
+ });
2843
2828
 
2844
- var matcher = matcherFactory(this.util, this.customEqualityTesters),
2845
- matcherCompare = matcher.compare;
2829
+ /**
2830
+ * Asynchronous matchers.
2831
+ * @namespace async-matchers
2832
+ */
2833
+ function AsyncExpectation(options) {
2834
+ var global = options.global || j$.getGlobal();
2835
+ this.expector = new j$.Expector(options);
2846
2836
 
2847
- function defaultNegativeCompare() {
2848
- var result = matcher.compare.apply(null, args);
2849
- result.pass = !result.pass;
2850
- return result;
2851
- }
2837
+ if (!global.Promise) {
2838
+ throw new Error('expectAsync is unavailable because the environment does not support promises.');
2839
+ }
2852
2840
 
2853
- if (this.isNot) {
2854
- matcherCompare = matcher.negativeCompare || defaultNegativeCompare;
2855
- }
2841
+ if (!j$.isPromiseLike(this.expector.actual)) {
2842
+ throw new Error('Expected expectAsync to be called with a promise.');
2843
+ }
2844
+ }
2856
2845
 
2857
- var result = matcherCompare.apply(null, args);
2858
- message = Expectation.finalizeMessage(this.util, name, this.isNot, args, result);
2846
+ /**
2847
+ * Add some context for an {@link expectAsync}
2848
+ * @function
2849
+ * @name async-matchers#withContext
2850
+ * @param {String} message - Additional context to show when the async matcher fails
2851
+ * @return {async-matchers}
2852
+ */
2853
+ AsyncExpectation.prototype.withContext = function withContext(message) {
2854
+ return addFilter(this, new ContextAddingFilter(message));
2855
+ };
2859
2856
 
2860
- if (expected.length == 1) {
2861
- expected = expected[0];
2862
- }
2857
+ /**
2858
+ * Invert the matcher following this {@link expectAsync}
2859
+ * @member
2860
+ * @name async-matchers#not
2861
+ * @type {async-matchers}
2862
+ * @example
2863
+ * await expectAsync(myPromise).not.toBeResolved();
2864
+ * @example
2865
+ * return expectAsync(myPromise).not.toBeResolved();
2866
+ */
2867
+ Object.defineProperty(AsyncExpectation.prototype, 'not', {
2868
+ get: function() {
2869
+ return addFilter(this, asyncNegatingFilter);
2870
+ }
2871
+ });
2863
2872
 
2864
- // TODO: how many of these params are needed?
2865
- this.addExpectationResult(
2866
- result.pass,
2867
- {
2868
- matcherName: name,
2869
- passed: result.pass,
2870
- message: message,
2871
- error: result.error,
2872
- actual: this.actual,
2873
- expected: expected // TODO: this may need to be arrayified/sliced
2874
- }
2875
- );
2873
+ function wrapSyncCompare(name, matcherFactory) {
2874
+ return function() {
2875
+ var result = this.expector.compare(name, matcherFactory, arguments);
2876
+ this.expector.processResult(result);
2876
2877
  };
2877
- };
2878
+ }
2878
2879
 
2879
- Expectation.finalizeMessage = function(util, name, isNot, args, result) {
2880
- if (result.pass) {
2881
- return '';
2882
- } else if (result.message) {
2883
- if (Object.prototype.toString.apply(result.message) === '[object Function]') {
2880
+ function wrapAsyncCompare(name, matcherFactory) {
2881
+ return function() {
2882
+ var self = this;
2883
+
2884
+ // Capture the call stack here, before we go async, so that it will contain
2885
+ // frames that are relevant to the user instead of just parts of Jasmine.
2886
+ var errorForStack = j$.util.errorWithStack();
2887
+
2888
+ return this.expector.compare(name, matcherFactory, arguments).then(function(result) {
2889
+ self.expector.processResult(result, errorForStack, promiseForMessage);
2890
+ });
2891
+ };
2892
+ }
2893
+
2894
+ function addCoreMatchers(prototype, matchers, wrapper) {
2895
+ for (var matcherName in matchers) {
2896
+ var matcher = matchers[matcherName];
2897
+ prototype[matcherName] = wrapper(matcherName, matcher);
2898
+ }
2899
+ }
2900
+
2901
+ function addFilter(source, filter) {
2902
+ var result = Object.create(source);
2903
+ result.expector = source.expector.addFilter(filter);
2904
+ return result;
2905
+ }
2906
+
2907
+ function negatedFailureMessage(result, matcherName, args, util) {
2908
+ if (result.message) {
2909
+ if (j$.isFunction_(result.message)) {
2884
2910
  return result.message();
2885
2911
  } else {
2886
2912
  return result.message;
2887
2913
  }
2888
- } else {
2889
- args = args.slice();
2890
- args.unshift(isNot);
2891
- args.unshift(name);
2892
- return util.buildFailureMessage.apply(null, args);
2893
2914
  }
2915
+
2916
+ args = args.slice();
2917
+ args.unshift(true);
2918
+ args.unshift(matcherName);
2919
+ return util.buildFailureMessage.apply(null, args);
2920
+ }
2921
+
2922
+ function negate(result) {
2923
+ result.pass = !result.pass;
2924
+ return result;
2925
+ }
2926
+
2927
+ var syncNegatingFilter = {
2928
+ selectComparisonFunc: function(matcher) {
2929
+ function defaultNegativeCompare() {
2930
+ return negate(matcher.compare.apply(null, arguments));
2931
+ }
2932
+
2933
+ return matcher.negativeCompare || defaultNegativeCompare;
2934
+ },
2935
+ buildFailureMessage: negatedFailureMessage
2894
2936
  };
2895
2937
 
2896
- Expectation.addCoreMatchers = function(matchers) {
2897
- var prototype = Expectation.prototype;
2898
- for (var matcherName in matchers) {
2899
- var matcher = matchers[matcherName];
2900
- prototype[matcherName] = prototype.wrapCompare(matcherName, matcher);
2938
+ var asyncNegatingFilter = {
2939
+ selectComparisonFunc: function(matcher) {
2940
+ function defaultNegativeCompare() {
2941
+ return matcher.compare.apply(this, arguments).then(negate);
2942
+ }
2943
+
2944
+ return defaultNegativeCompare;
2945
+ },
2946
+ buildFailureMessage: negatedFailureMessage
2947
+ };
2948
+
2949
+ function ContextAddingFilter(message) {
2950
+ this.message = message;
2951
+ }
2952
+
2953
+ ContextAddingFilter.prototype.modifyFailureMessage = function(msg) {
2954
+ return this.message + ': ' + msg;
2955
+ };
2956
+
2957
+ return {
2958
+ factory: function(options) {
2959
+ return new Expectation(options || {});
2960
+ },
2961
+ addCoreMatchers: function(matchers) {
2962
+ addCoreMatchers(Expectation.prototype, matchers, wrapSyncCompare);
2963
+ },
2964
+ asyncFactory: function(options) {
2965
+ return new AsyncExpectation(options || {});
2966
+ },
2967
+ addAsyncCoreMatchers: function(matchers) {
2968
+ addCoreMatchers(AsyncExpectation.prototype, matchers, wrapAsyncCompare);
2901
2969
  }
2902
2970
  };
2971
+ };
2903
2972
 
2904
- Expectation.Factory = function(options) {
2905
- options = options || {};
2973
+ getJasmineRequireObj().ExpectationFilterChain = function() {
2974
+ function ExpectationFilterChain(maybeFilter, prev) {
2975
+ this.filter_ = maybeFilter;
2976
+ this.prev_ = prev;
2977
+ }
2906
2978
 
2907
- var expect = new Expectation(options);
2979
+ ExpectationFilterChain.prototype.addFilter = function(filter) {
2980
+ return new ExpectationFilterChain(filter, this);
2981
+ };
2982
+
2983
+ ExpectationFilterChain.prototype.selectComparisonFunc = function(matcher) {
2984
+ return this.callFirst_('selectComparisonFunc', arguments).result;
2985
+ };
2908
2986
 
2909
- // TODO: this would be nice as its own Object - NegativeExpectation
2910
- // TODO: copy instead of mutate options
2911
- options.isNot = true;
2912
- expect.not = new Expectation(options);
2987
+ ExpectationFilterChain.prototype.buildFailureMessage = function(result, matcherName, args, util) {
2988
+ return this.callFirst_('buildFailureMessage', arguments).result;
2989
+ };
2913
2990
 
2914
- return expect;
2991
+ ExpectationFilterChain.prototype.modifyFailureMessage = function(msg) {
2992
+ var result = this.callFirst_('modifyFailureMessage', arguments).result;
2993
+ return result || msg;
2915
2994
  };
2916
2995
 
2917
- return Expectation;
2996
+ ExpectationFilterChain.prototype.callFirst_ = function(fname, args) {
2997
+ var prevResult;
2998
+
2999
+ if (this.prev_) {
3000
+ prevResult = this.prev_.callFirst_(fname, args);
3001
+
3002
+ if (prevResult.found) {
3003
+ return prevResult;
3004
+ }
3005
+ }
3006
+
3007
+ if (this.filter_ && this.filter_[fname]) {
3008
+ return {
3009
+ found: true,
3010
+ result: this.filter_[fname].apply(this.filter_, args)
3011
+ };
3012
+ }
3013
+
3014
+ return {found: false};
3015
+ };
3016
+
3017
+ return ExpectationFilterChain;
2918
3018
  };
2919
3019
 
2920
3020
  //TODO: expectation result may make more sense as a presentation of an expectation.
@@ -2983,6 +3083,87 @@ getJasmineRequireObj().buildExpectationResult = function() {
2983
3083
  return buildExpectationResult;
2984
3084
  };
2985
3085
 
3086
+ getJasmineRequireObj().Expector = function(j$) {
3087
+ function Expector(options) {
3088
+ this.util = options.util || { buildFailureMessage: function() {} };
3089
+ this.customEqualityTesters = options.customEqualityTesters || [];
3090
+ this.actual = options.actual;
3091
+ this.addExpectationResult = options.addExpectationResult || function(){};
3092
+ this.filters = new j$.ExpectationFilterChain();
3093
+ }
3094
+
3095
+ Expector.prototype.instantiateMatcher = function(matcherName, matcherFactory, args) {
3096
+ this.matcherName = matcherName;
3097
+ this.args = Array.prototype.slice.call(args, 0);
3098
+ this.expected = this.args.slice(0);
3099
+
3100
+ this.args.unshift(this.actual);
3101
+
3102
+ var matcher = matcherFactory(this.util, this.customEqualityTesters);
3103
+ var comparisonFunc = this.filters.selectComparisonFunc(matcher);
3104
+ return comparisonFunc || matcher.compare;
3105
+ };
3106
+
3107
+ Expector.prototype.buildMessage = function(result) {
3108
+ var self = this;
3109
+
3110
+ if (result.pass) {
3111
+ return '';
3112
+ }
3113
+
3114
+ var msg = this.filters.buildFailureMessage(result, this.matcherName, this.args, this.util, defaultMessage);
3115
+ return this.filters.modifyFailureMessage(msg || defaultMessage());
3116
+
3117
+ function defaultMessage() {
3118
+ if (!result.message) {
3119
+ var args = self.args.slice();
3120
+ args.unshift(false);
3121
+ args.unshift(self.matcherName);
3122
+ return self.util.buildFailureMessage.apply(null, args);
3123
+ } else if (j$.isFunction_(result.message)) {
3124
+ return result.message();
3125
+ } else {
3126
+ return result.message;
3127
+ }
3128
+ }
3129
+ };
3130
+
3131
+ Expector.prototype.compare = function(matcherName, matcherFactory, args) {
3132
+ var matcherCompare = this.instantiateMatcher(matcherName, matcherFactory, args);
3133
+ return matcherCompare.apply(null, this.args);
3134
+ };
3135
+
3136
+ Expector.prototype.addFilter = function(filter) {
3137
+ var result = Object.create(this);
3138
+ result.filters = this.filters.addFilter(filter);
3139
+ return result;
3140
+ };
3141
+
3142
+ Expector.prototype.processResult = function(result, errorForStack, actualOverride) {
3143
+ this.args[0] = actualOverride || this.args[0];
3144
+ var message = this.buildMessage(result);
3145
+
3146
+ if (this.expected.length === 1) {
3147
+ this.expected = this.expected[0];
3148
+ }
3149
+
3150
+ this.addExpectationResult(
3151
+ result.pass,
3152
+ {
3153
+ matcherName: this.matcherName,
3154
+ passed: result.pass,
3155
+ message: message,
3156
+ error: errorForStack ? undefined : result.error,
3157
+ errorForStack: errorForStack || undefined,
3158
+ actual: this.actual,
3159
+ expected: this.expected // TODO: this may need to be arrayified/sliced
3160
+ }
3161
+ );
3162
+ };
3163
+
3164
+ return Expector;
3165
+ };
3166
+
2986
3167
  getJasmineRequireObj().formatErrorMsg = function() {
2987
3168
  function generateErrorMsg(domain, usage) {
2988
3169
  var usageDefinition = usage ? '\nUsage: ' + usage : '';
@@ -3055,6 +3236,146 @@ getJasmineRequireObj().GlobalErrors = function(j$) {
3055
3236
  return GlobalErrors;
3056
3237
  };
3057
3238
 
3239
+ getJasmineRequireObj().toBeRejected = function(j$) {
3240
+ /**
3241
+ * Expect a promise to be rejected.
3242
+ * @function
3243
+ * @async
3244
+ * @name async-matchers#toBeRejected
3245
+ * @example
3246
+ * await expectAsync(aPromise).toBeRejected();
3247
+ * @example
3248
+ * return expectAsync(aPromise).toBeRejected();
3249
+ */
3250
+ return function toBeResolved(util) {
3251
+ return {
3252
+ compare: function(actual) {
3253
+ return actual.then(
3254
+ function() { return {pass: false}; },
3255
+ function() { return {pass: true}; }
3256
+ );
3257
+ }
3258
+ };
3259
+ };
3260
+ };
3261
+
3262
+ getJasmineRequireObj().toBeRejectedWith = function(j$) {
3263
+ /**
3264
+ * Expect a promise to be rejected with a value equal to the expected, using deep equality comparison.
3265
+ * @function
3266
+ * @async
3267
+ * @name async-matchers#toBeRejectedWith
3268
+ * @param {Object} expected - Value that the promise is expected to be rejected with
3269
+ * @example
3270
+ * await expectAsync(aPromise).toBeRejectedWith({prop: 'value'});
3271
+ * @example
3272
+ * return expectAsync(aPromise).toBeRejectedWith({prop: 'value'});
3273
+ */
3274
+ return function toBeRejectedWith(util, customEqualityTesters) {
3275
+ return {
3276
+ compare: function(actualPromise, expectedValue) {
3277
+ function prefix(passed) {
3278
+ return 'Expected a promise ' +
3279
+ (passed ? 'not ' : '') +
3280
+ 'to be rejected with ' + j$.pp(expectedValue);
3281
+ }
3282
+
3283
+ return actualPromise.then(
3284
+ function() {
3285
+ return {
3286
+ pass: false,
3287
+ message: prefix(false) + ' but it was resolved.'
3288
+ };
3289
+ },
3290
+ function(actualValue) {
3291
+ if (util.equals(actualValue, expectedValue, customEqualityTesters)) {
3292
+ return {
3293
+ pass: true,
3294
+ message: prefix(true) + '.'
3295
+ };
3296
+ } else {
3297
+ return {
3298
+ pass: false,
3299
+ message: prefix(false) + ' but it was rejected with ' + j$.pp(actualValue) + '.'
3300
+ };
3301
+ }
3302
+ }
3303
+ );
3304
+ }
3305
+ };
3306
+ };
3307
+ };
3308
+
3309
+ getJasmineRequireObj().toBeResolved = function(j$) {
3310
+ /**
3311
+ * Expect a promise to be resolved.
3312
+ * @function
3313
+ * @async
3314
+ * @name async-matchers#toBeResolved
3315
+ * @example
3316
+ * await expectAsync(aPromise).toBeResolved();
3317
+ * @example
3318
+ * return expectAsync(aPromise).toBeResolved();
3319
+ */
3320
+ return function toBeResolved(util) {
3321
+ return {
3322
+ compare: function(actual) {
3323
+ return actual.then(
3324
+ function() { return {pass: true}; },
3325
+ function() { return {pass: false}; }
3326
+ );
3327
+ }
3328
+ };
3329
+ };
3330
+ };
3331
+
3332
+ getJasmineRequireObj().toBeResolvedTo = function(j$) {
3333
+ /**
3334
+ * Expect a promise to be resolved to a value equal to the expected, using deep equality comparison.
3335
+ * @function
3336
+ * @async
3337
+ * @name async-matchers#toBeResolvedTo
3338
+ * @param {Object} expected - Value that the promise is expected to resolve to
3339
+ * @example
3340
+ * await expectAsync(aPromise).toBeResolvedTo({prop: 'value'});
3341
+ * @example
3342
+ * return expectAsync(aPromise).toBeResolvedTo({prop: 'value'});
3343
+ */
3344
+ return function toBeResolvedTo(util, customEqualityTesters) {
3345
+ return {
3346
+ compare: function(actualPromise, expectedValue) {
3347
+ function prefix(passed) {
3348
+ return 'Expected a promise ' +
3349
+ (passed ? 'not ' : '') +
3350
+ 'to be resolved to ' + j$.pp(expectedValue);
3351
+ }
3352
+
3353
+ return actualPromise.then(
3354
+ function(actualValue) {
3355
+ if (util.equals(actualValue, expectedValue, customEqualityTesters)) {
3356
+ return {
3357
+ pass: true,
3358
+ message: prefix(true) + '.'
3359
+ };
3360
+ } else {
3361
+ return {
3362
+ pass: false,
3363
+ message: prefix(false) + ' but it was resolved to ' + j$.pp(actualValue) + '.'
3364
+ };
3365
+ }
3366
+ },
3367
+ function() {
3368
+ return {
3369
+ pass: false,
3370
+ message: prefix(false) + ' but it was rejected.'
3371
+ };
3372
+ }
3373
+ );
3374
+ }
3375
+ };
3376
+ };
3377
+ };
3378
+
3058
3379
  getJasmineRequireObj().DiffBuilder = function(j$) {
3059
3380
  return function DiffBuilder() {
3060
3381
  var path = new j$.ObjectPath(),
@@ -3645,7 +3966,24 @@ getJasmineRequireObj().ObjectPath = function(j$) {
3645
3966
  return ObjectPath;
3646
3967
  };
3647
3968
 
3648
- getJasmineRequireObj().toBe = function() {
3969
+ getJasmineRequireObj().requireAsyncMatchers = function(jRequire, j$) {
3970
+ var availableMatchers = [
3971
+ 'toBeResolved',
3972
+ 'toBeRejected',
3973
+ 'toBeResolvedTo',
3974
+ 'toBeRejectedWith'
3975
+ ],
3976
+ matchers = {};
3977
+
3978
+ for (var i = 0; i < availableMatchers.length; i++) {
3979
+ var name = availableMatchers[i];
3980
+ matchers[name] = jRequire[name](j$);
3981
+ }
3982
+
3983
+ return matchers;
3984
+ };
3985
+
3986
+ getJasmineRequireObj().toBe = function(j$) {
3649
3987
  /**
3650
3988
  * {@link expect} the actual value to be `===` to the expected value.
3651
3989
  * @function
@@ -3654,12 +3992,20 @@ getJasmineRequireObj().toBe = function() {
3654
3992
  * @example
3655
3993
  * expect(thing).toBe(realThing);
3656
3994
  */
3657
- function toBe() {
3995
+ function toBe(util) {
3996
+ var tip = ' Tip: To check for deep equality, use .toEqual() instead of .toBe().';
3997
+
3658
3998
  return {
3659
3999
  compare: function(actual, expected) {
3660
- return {
3661
- pass: actual === expected
4000
+ var result = {
4001
+ pass: actual === expected,
3662
4002
  };
4003
+
4004
+ if (typeof expected === 'object') {
4005
+ result.message = util.buildFailureMessage('toBe', result.pass, actual, expected) + tip;
4006
+ }
4007
+
4008
+ return result;
3663
4009
  }
3664
4010
  };
3665
4011
  }
@@ -4994,26 +5340,29 @@ getJasmineRequireObj().QueueRunner = function(j$) {
4994
5340
 
4995
5341
  function once(fn) {
4996
5342
  var called = false;
4997
- return function() {
5343
+ return function(arg) {
4998
5344
  if (!called) {
4999
5345
  called = true;
5000
- fn.apply(null, arguments);
5346
+ // Direct call using single parameter, because cleanup/next does not need more
5347
+ fn(arg);
5001
5348
  }
5002
5349
  return null;
5003
5350
  };
5004
5351
  }
5005
5352
 
5353
+ function emptyFn() {}
5354
+
5006
5355
  function QueueRunner(attrs) {
5007
5356
  var queueableFns = attrs.queueableFns || [];
5008
5357
  this.queueableFns = queueableFns.concat(attrs.cleanupFns || []);
5009
5358
  this.firstCleanupIx = queueableFns.length;
5010
- this.onComplete = attrs.onComplete || function() {};
5359
+ this.onComplete = attrs.onComplete || emptyFn;
5011
5360
  this.clearStack = attrs.clearStack || function(fn) {fn();};
5012
- this.onException = attrs.onException || function() {};
5361
+ this.onException = attrs.onException || emptyFn;
5013
5362
  this.userContext = attrs.userContext || new j$.UserContext();
5014
5363
  this.timeout = attrs.timeout || {setTimeout: setTimeout, clearTimeout: clearTimeout};
5015
- this.fail = attrs.fail || function() {};
5016
- this.globalErrors = attrs.globalErrors || { pushListener: function() {}, popListener: function() {} };
5364
+ this.fail = attrs.fail || emptyFn;
5365
+ this.globalErrors = attrs.globalErrors || { pushListener: emptyFn, popListener: emptyFn };
5017
5366
  this.completeOnFirstError = !!attrs.completeOnFirstError;
5018
5367
  this.errored = false;
5019
5368
 
@@ -5055,7 +5404,9 @@ getJasmineRequireObj().QueueRunner = function(j$) {
5055
5404
  next(error);
5056
5405
  },
5057
5406
  cleanup = once(function cleanup() {
5058
- self.clearTimeout(timeoutId);
5407
+ if (timeoutId !== void 0) {
5408
+ self.clearTimeout(timeoutId);
5409
+ }
5059
5410
  self.globalErrors.popListener(handleError);
5060
5411
  }),
5061
5412
  next = once(function next(err) {
@@ -6617,5 +6968,5 @@ getJasmineRequireObj().UserContext = function(j$) {
6617
6968
  };
6618
6969
 
6619
6970
  getJasmineRequireObj().version = function() {
6620
- return '3.2.1';
6971
+ return '3.3.0';
6621
6972
  };