mocha 3.0.0-1 → 3.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/lib/runner.js CHANGED
@@ -10,6 +10,7 @@ var debug = require('debug')('mocha:runner');
10
10
  var Runnable = require('./runnable');
11
11
  var filter = utils.filter;
12
12
  var indexOf = utils.indexOf;
13
+ var some = utils.some;
13
14
  var keys = utils.keys;
14
15
  var stackFilter = utils.stackTraceFilter();
15
16
  var stringify = utils.stringify;
@@ -846,16 +847,38 @@ Runner.prototype.abort = function() {
846
847
  * @api private
847
848
  */
848
849
  function filterOnly(suite) {
849
- // If it has `only` tests, run only those
850
- if (suite.onlyTests) {
851
- suite.tests = suite.onlyTests;
852
- }
853
- // Filter the nested suites
854
- suite.suites = filter(suite.suites, filterOnly);
855
- // Don't run tests from suites that are not marked as `only`
856
- suite.tests = suite.isOnly ? suite.tests : [];
850
+ if (suite._onlyTests.length) {
851
+ // If the suite contains `only` tests, run those and ignore any nested suites.
852
+ suite.tests = suite._onlyTests;
853
+ suite.suites = [];
854
+ } else {
855
+ // Otherwise, do not run any of the tests in this suite.
856
+ suite.tests = [];
857
+ suite._onlySuites.forEach(function(onlySuite) {
858
+ // If there are other `only` tests/suites nested in the current `only` suite, then filter that `only` suite.
859
+ // Otherwise, all of the tests on this `only` suite should be run, so don't filter it.
860
+ if (hasOnly(onlySuite)) {
861
+ filterOnly(onlySuite);
862
+ }
863
+ });
864
+ // Run the `only` suites, as well as any other suites that have `only` tests/suites as descendants.
865
+ suite.suites = filter(suite.suites, function(childSuite) {
866
+ return indexOf(suite._onlySuites, childSuite) !== -1 || filterOnly(childSuite);
867
+ });
868
+ }
857
869
  // Keep the suite only if there is something to run
858
- return suite.suites.length || suite.tests.length;
870
+ return suite.tests.length || suite.suites.length;
871
+ }
872
+
873
+ /**
874
+ * Determines whether a suite has an `only` test or suite as a descendant.
875
+ *
876
+ * @param {Array} suite
877
+ * @returns {Boolean}
878
+ * @api private
879
+ */
880
+ function hasOnly(suite) {
881
+ return suite._onlyTests.length || suite._onlySuites.length || some(suite.suites, hasOnly);
859
882
  }
860
883
 
861
884
  /**
package/lib/suite.js CHANGED
@@ -61,6 +61,8 @@ function Suite(title, parentContext) {
61
61
  this._slow = 75;
62
62
  this._bail = false;
63
63
  this._retries = -1;
64
+ this._onlyTests = [];
65
+ this._onlySuites = [];
64
66
  this.delayed = false;
65
67
  }
66
68
 
@@ -0,0 +1,19 @@
1
+ Copyright (c) 2016 Segment.io, Inc. (friends@segment.com)
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy
4
+ of this software and associated documentation files (the "Software"), to deal
5
+ in the Software without restriction, including without limitation the rights
6
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7
+ copies of the Software, and to permit persons to whom the Software is
8
+ furnished to do so, subject to the following conditions:
9
+
10
+ The above copyright notice and this permission notice shall be included in
11
+ all copies or substantial portions of the Software.
12
+
13
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19
+ THE SOFTWARE.
@@ -0,0 +1,37 @@
1
+ 'use strict';
2
+
3
+ /**
4
+ * Pad a `number` with a ten's place zero.
5
+ *
6
+ * @param {number} number
7
+ * @return {string}
8
+ */
9
+ function pad(number) {
10
+ var n = number.toString();
11
+ return n.length === 1 ? '0' + n : n;
12
+ }
13
+
14
+ /**
15
+ * Turn a `date` into an ISO string.
16
+ *
17
+ * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString
18
+ *
19
+ * @param {Date} date
20
+ * @return {string}
21
+ */
22
+ function toISOString(date) {
23
+ return date.getUTCFullYear()
24
+ + '-' + pad(date.getUTCMonth() + 1)
25
+ + '-' + pad(date.getUTCDate())
26
+ + 'T' + pad(date.getUTCHours())
27
+ + ':' + pad(date.getUTCMinutes())
28
+ + ':' + pad(date.getUTCSeconds())
29
+ + '.' + String((date.getUTCMilliseconds()/1000).toFixed(3)).slice(2, 5)
30
+ + 'Z';
31
+ }
32
+
33
+ /*
34
+ * Exports.
35
+ */
36
+
37
+ module.exports = toISOString;
package/lib/utils.js CHANGED
@@ -13,7 +13,7 @@ var join = require('path').join;
13
13
  var readdirSync = require('fs').readdirSync;
14
14
  var statSync = require('fs').statSync;
15
15
  var watchFile = require('fs').watchFile;
16
- var toISOString = require('to-iso-string');
16
+ var toISOString = require('./to-iso-string');
17
17
 
18
18
  /**
19
19
  * Ignored directories.
@@ -138,6 +138,23 @@ exports.filter = function(arr, fn) {
138
138
  return ret;
139
139
  };
140
140
 
141
+ /**
142
+ * Array#some (<=IE8)
143
+ *
144
+ * @api private
145
+ * @param {Array} arr
146
+ * @param {Function} fn
147
+ * @return {Array}
148
+ */
149
+ exports.some = function(arr, fn) {
150
+ for (var i = 0, l = arr.length; i < l; i++) {
151
+ if (fn(arr[i])) {
152
+ return true;
153
+ }
154
+ }
155
+ return false;
156
+ };
157
+
141
158
  /**
142
159
  * Object.keys (<=IE8)
143
160
  *
package/mocha.css CHANGED
@@ -148,23 +148,28 @@ body {
148
148
  padding: 15px;
149
149
  border: 1px solid #eee;
150
150
  max-width: 85%; /*(1)*/
151
+ max-width: -webkit-calc(100% - 42px);
152
+ max-width: -moz-calc(100% - 42px);
151
153
  max-width: calc(100% - 42px); /*(2)*/
152
154
  max-height: 300px;
153
155
  word-wrap: break-word;
154
156
  border-bottom-color: #ddd;
155
- -webkit-border-radius: 3px;
156
157
  -webkit-box-shadow: 0 1px 3px #eee;
157
- -moz-border-radius: 3px;
158
158
  -moz-box-shadow: 0 1px 3px #eee;
159
+ box-shadow: 0 1px 3px #eee;
160
+ -webkit-border-radius: 3px;
161
+ -moz-border-radius: 3px;
159
162
  border-radius: 3px;
160
163
  }
161
164
 
162
165
  #mocha .test .html-error pre.error {
163
166
  border: none;
164
- -webkit-border-radius: none;
165
- -webkit-box-shadow: none;
166
- -moz-border-radius: none;
167
- -moz-box-shadow: none;
167
+ -webkit-border-radius: 0;
168
+ -moz-border-radius: 0;
169
+ border-radius: 0;
170
+ -webkit-box-shadow: 0;
171
+ -moz-box-shadow: 0;
172
+ box-shadow: 0;
168
173
  padding: 0;
169
174
  margin: 0;
170
175
  margin-top: 18px;
@@ -185,13 +190,16 @@ body {
185
190
  padding: 15px;
186
191
  border: 1px solid #eee;
187
192
  max-width: 85%; /*(1)*/
193
+ max-width: -webkit-calc(100% - 42px);
194
+ max-width: -moz-calc(100% - 42px);
188
195
  max-width: calc(100% - 42px); /*(2)*/
189
196
  word-wrap: break-word;
190
197
  border-bottom-color: #ddd;
191
- -webkit-border-radius: 3px;
192
198
  -webkit-box-shadow: 0 1px 3px #eee;
193
- -moz-border-radius: 3px;
194
199
  -moz-box-shadow: 0 1px 3px #eee;
200
+ box-shadow: 0 1px 3px #eee;
201
+ -webkit-border-radius: 3px;
202
+ -moz-border-radius: 3px;
195
203
  border-radius: 3px;
196
204
  }
197
205
 
@@ -212,10 +220,12 @@ body {
212
220
  text-align: center;
213
221
  background: #eee;
214
222
  font-size: 15px;
223
+ -webkit-border-radius: 15px;
215
224
  -moz-border-radius: 15px;
216
225
  border-radius: 15px;
217
- -webkit-transition: opacity 200ms;
218
- -moz-transition: opacity 200ms;
226
+ -webkit-transition:opacity 200ms;
227
+ -moz-transition:opacity 200ms;
228
+ -o-transition:opacity 200ms;
219
229
  transition: opacity 200ms;
220
230
  opacity: 0.3;
221
231
  color: #888;
@@ -261,13 +271,15 @@ body {
261
271
  #mocha-stats .progress {
262
272
  float: right;
263
273
  padding-top: 0;
264
-
274
+
265
275
  /**
266
276
  * Set safe initial values, so mochas .progress does not inherit these
267
277
  * properties from Bootstrap .progress (which causes .progress height to
268
278
  * equal line height set in Bootstrap).
269
279
  */
270
280
  height: auto;
281
+ -webkit-box-shadow: none;
282
+ -moz-box-shadow: none;
271
283
  box-shadow: none;
272
284
  background-color: initial;
273
285
  }