teaspoon-mocha 2.2.4 → 2.3.3

Sign up to get free protection for your applications and to get access to all the features.
@@ -80,7 +80,7 @@
80
80
  var e;
81
81
  Teaspoon.messages.push(arguments[0]);
82
82
  try {
83
- return console.log.apply(console, arguments);
83
+ return typeof console !== "undefined" && console !== null ? typeof console.log === "function" ? console.log.apply(console, arguments) : void 0 : void 0;
84
84
  } catch (_error) {
85
85
  e = _error;
86
86
  throw new Error("Unable to use console.log for logging");
@@ -126,6 +126,46 @@
126
126
 
127
127
  })();
128
128
 
129
+ }).call(this);
130
+ (function() {
131
+ Teaspoon.Mixins || (Teaspoon.Mixins = {});
132
+
133
+ }).call(this);
134
+ (function() {
135
+ Teaspoon.Mixins.FilterUrl = {
136
+ filterUrl: function(grep) {
137
+ var params;
138
+ params = [];
139
+ params.push("grep=" + (encodeURIComponent(grep)));
140
+ if (Teaspoon.params.file) {
141
+ params.push("file=" + Teaspoon.params.file);
142
+ }
143
+ return "?" + (params.join("&"));
144
+ }
145
+ };
146
+
147
+ }).call(this);
148
+ (function() {
149
+ Teaspoon.Utility = (function() {
150
+ function Utility() {}
151
+
152
+ Utility.extend = function(obj, mixin) {
153
+ var method, name;
154
+ for (name in mixin) {
155
+ method = mixin[name];
156
+ obj[name] = method;
157
+ }
158
+ return obj;
159
+ };
160
+
161
+ Utility.include = function(klass, mixin) {
162
+ return this.extend(klass.prototype, mixin);
163
+ };
164
+
165
+ return Utility;
166
+
167
+ })();
168
+
129
169
  }).call(this);
130
170
  (function() {
131
171
  Teaspoon.Runner = (function() {
@@ -180,7 +220,7 @@
180
220
  var slice = [].slice;
181
221
 
182
222
  Teaspoon.Fixture = (function() {
183
- var addContent, cleanup, create, load, loadComplete, preload, putContent, set, xhr, xhrRequest;
223
+ var addContent, cleanup, create, jQueryAvailable, load, loadComplete, preload, putContent, set, xhr, xhrRequest;
184
224
 
185
225
  Fixture.cache = {};
186
226
 
@@ -191,19 +231,19 @@
191
231
  Fixture.json = [];
192
232
 
193
233
  Fixture.preload = function() {
194
- var i, len, results, url, urls;
234
+ var j, len, results, url, urls;
195
235
  urls = 1 <= arguments.length ? slice.call(arguments, 0) : [];
196
236
  results = [];
197
- for (i = 0, len = urls.length; i < len; i++) {
198
- url = urls[i];
237
+ for (j = 0, len = urls.length; j < len; j++) {
238
+ url = urls[j];
199
239
  results.push(preload(url));
200
240
  }
201
241
  return results;
202
242
  };
203
243
 
204
244
  Fixture.load = function() {
205
- var append, i, index, j, len, results, url, urls;
206
- urls = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), append = arguments[i++];
245
+ var append, index, j, k, len, results, url, urls;
246
+ urls = 2 <= arguments.length ? slice.call(arguments, 0, j = arguments.length - 1) : (j = 0, []), append = arguments[j++];
207
247
  if (append == null) {
208
248
  append = false;
209
249
  }
@@ -212,7 +252,7 @@
212
252
  append = false;
213
253
  }
214
254
  results = [];
215
- for (index = j = 0, len = urls.length; j < len; index = ++j) {
255
+ for (index = k = 0, len = urls.length; k < len; index = ++k) {
216
256
  url = urls[index];
217
257
  results.push(load(url, append || index > 0));
218
258
  }
@@ -220,8 +260,8 @@
220
260
  };
221
261
 
222
262
  Fixture.set = function() {
223
- var append, html, htmls, i, index, j, len, results;
224
- htmls = 2 <= arguments.length ? slice.call(arguments, 0, i = arguments.length - 1) : (i = 0, []), append = arguments[i++];
263
+ var append, html, htmls, index, j, k, len, results;
264
+ htmls = 2 <= arguments.length ? slice.call(arguments, 0, j = arguments.length - 1) : (j = 0, []), append = arguments[j++];
225
265
  if (append == null) {
226
266
  append = false;
227
267
  }
@@ -230,7 +270,7 @@
230
270
  append = false;
231
271
  }
232
272
  results = [];
233
- for (index = j = 0, len = htmls.length; j < len; index = ++j) {
273
+ for (index = k = 0, len = htmls.length; k < len; index = ++k) {
234
274
  html = htmls[index];
235
275
  results.push(set(html, append || index > 0));
236
276
  }
@@ -301,21 +341,30 @@
301
341
 
302
342
  putContent = function(content) {
303
343
  cleanup();
304
- create();
305
- return window.fixture.el.innerHTML = content;
344
+ return addContent(content);
306
345
  };
307
346
 
308
347
  addContent = function(content) {
348
+ var i, j, parsed, ref, results;
309
349
  if (!window.fixture.el) {
310
350
  create();
311
351
  }
312
- return window.fixture.el.innerHTML += content;
352
+ if (jQueryAvailable()) {
353
+ parsed = $($.parseHTML(content, document, true));
354
+ results = [];
355
+ for (i = j = 0, ref = parsed.length; 0 <= ref ? j < ref : j > ref; i = 0 <= ref ? ++j : --j) {
356
+ results.push(window.fixture.el.appendChild(parsed[i]));
357
+ }
358
+ return results;
359
+ } else {
360
+ return window.fixture.el.innerHTML += content;
361
+ }
313
362
  };
314
363
 
315
364
  create = function() {
316
365
  var ref;
317
366
  window.fixture.el = document.createElement("div");
318
- if (typeof window.$ === 'function') {
367
+ if (jQueryAvailable()) {
319
368
  window.fixture.$el = $(window.fixture.el);
320
369
  }
321
370
  window.fixture.el.id = "teaspoon-fixtures";
@@ -357,6 +406,10 @@
357
406
  return xhr.send();
358
407
  };
359
408
 
409
+ jQueryAvailable = function() {
410
+ return typeof window.$ === 'function';
411
+ };
412
+
360
413
  return Fixture;
361
414
 
362
415
  })();
@@ -405,6 +458,28 @@
405
458
  });
406
459
  };
407
460
 
461
+ }).call(this);
462
+ (function() {
463
+ Teaspoon.Spec = (function() {
464
+ function Spec() {}
465
+
466
+ Teaspoon.Utility.include(Spec, Teaspoon.Mixins.FilterUrl);
467
+
468
+ return Spec;
469
+
470
+ })();
471
+
472
+ }).call(this);
473
+ (function() {
474
+ Teaspoon.Suite = (function() {
475
+ function Suite() {}
476
+
477
+ Teaspoon.Utility.include(Suite, Teaspoon.Mixins.FilterUrl);
478
+
479
+ return Suite;
480
+
481
+ })();
482
+
408
483
  }).call(this);
409
484
  (function() {
410
485
  Teaspoon.Reporters.BaseView = (function() {
@@ -547,7 +622,7 @@
547
622
  this.setText("stats-passes", this.total.passes);
548
623
  this.setText("stats-failures", this.total.failures);
549
624
  if (this.total.run < this.total.exist) {
550
- this.total.skipped = this.total.exist - this.total.run;
625
+ this.total.skipped = this.total.exist - this.total.run + this.total.skipped;
551
626
  this.total.run = this.total.exist;
552
627
  }
553
628
  this.setText("stats-skipped", this.total.skipped);
@@ -568,7 +643,8 @@
568
643
  HTML.prototype.reportSpecResults = function(spec) {
569
644
  this.total.run += 1;
570
645
  this.updateProgress();
571
- return this.updateStatus(spec);
646
+ this.updateStatus(spec);
647
+ return delete this.reportView;
572
648
  };
573
649
 
574
650
  HTML.prototype.buildLayout = function() {
@@ -623,27 +699,24 @@
623
699
  };
624
700
 
625
701
  HTML.prototype.updateStatus = function(spec) {
626
- var elapsed, ref, ref1, ref2, result;
627
- result = spec.result();
628
- if (result.skipped) {
629
- this.updateStat("skipped", this.total.skipped += 1);
630
- return;
631
- }
702
+ var elapsed, ref, result;
632
703
  elapsed = new Teaspoon.Date().getTime() - this.specStart;
633
- if (result.status === "passed") {
634
- this.updateStat("passes", this.total.passes += 1);
635
- return (ref = this.reportView) != null ? ref.updateState("passed", elapsed) : void 0;
636
- } else if (result.status === "pending") {
637
- return (ref1 = this.reportView) != null ? ref1.updateState("pending", elapsed) : void 0;
638
- } else {
704
+ if ((ref = this.reportView) != null) {
705
+ ref.updateState(spec, elapsed);
706
+ }
707
+ result = spec.result();
708
+ if (result.status === "pending") {
709
+ return this.updateStat("skipped", this.total.skipped += 1);
710
+ } else if (result.status === "failed") {
639
711
  this.updateStat("failures", this.total.failures += 1);
640
- if ((ref2 = this.reportView) != null) {
641
- ref2.updateState("failed", elapsed);
642
- }
643
712
  if (!this.config["build-full-report"]) {
644
713
  new (Teaspoon.resolveClass("Reporters.HTML.FailureView"))(spec).appendTo(this.findEl("report-failures"));
645
714
  }
646
715
  return this.setStatus("failed");
716
+ } else if (result.skipped) {
717
+ return this.updateStat("skipped", this.total.skipped += 1);
718
+ } else {
719
+ return this.updateStat("passes", this.total.passes += 1);
647
720
  }
648
721
  };
649
722
 
@@ -896,8 +969,8 @@
896
969
 
897
970
  viewId = 0;
898
971
 
899
- function SpecView(spec, reporter) {
900
- this.spec = spec;
972
+ function SpecView(spec1, reporter) {
973
+ this.spec = spec1;
901
974
  this.reporter = reporter;
902
975
  this.views = this.reporter.views;
903
976
  this.spec.viewId = viewId += 1;
@@ -920,6 +993,9 @@
920
993
  SpecView.prototype.buildParent = function() {
921
994
  var parent, view;
922
995
  parent = this.spec.parent;
996
+ if (!parent) {
997
+ return this.reporter;
998
+ }
923
999
  if (parent.viewId) {
924
1000
  return this.views.suites[parent.viewId];
925
1001
  } else {
@@ -941,21 +1017,52 @@
941
1017
  return this.append(div);
942
1018
  };
943
1019
 
944
- SpecView.prototype.updateState = function(state, elapsed) {
945
- var base, classes, result;
946
- result = this.spec.result();
947
- classes = ["state-" + state];
948
- if (elapsed > Teaspoon.slow) {
949
- classes.push("slow");
950
- }
951
- if (state === "passed") {
952
- this.el.innerHTML += "<span>" + elapsed + "ms</span>";
1020
+ SpecView.prototype.updateState = function(spec, elapsed) {
1021
+ var result;
1022
+ result = spec.result();
1023
+ this.clearClasses();
1024
+ if (result.status === "pending") {
1025
+ return this.updatePending(spec, elapsed);
1026
+ } else if (result.status === "failed") {
1027
+ return this.updateFailed(spec, elapsed);
1028
+ } else if (result.skipped) {
1029
+ return this.updateDisabled(spec, elapsed);
1030
+ } else {
1031
+ return this.updatePassed(spec, elapsed);
953
1032
  }
954
- this.el.className = classes.join(" ");
955
- if (result.status === "failed") {
956
- this.buildErrors();
1033
+ };
1034
+
1035
+ SpecView.prototype.updatePassed = function(spec, elapsed) {
1036
+ this.addStatusClass("passed");
1037
+ if (elapsed > Teaspoon.slow) {
1038
+ this.addClass("slow");
957
1039
  }
958
- return typeof (base = this.parentView).updateState === "function" ? base.updateState(state) : void 0;
1040
+ return this.el.innerHTML += "<span>" + elapsed + "ms</span>";
1041
+ };
1042
+
1043
+ SpecView.prototype.updateFailed = function(spec, elapsed) {
1044
+ var base;
1045
+ this.addStatusClass("failed");
1046
+ this.buildErrors();
1047
+ return typeof (base = this.parentView).updateState === "function" ? base.updateState("failed") : void 0;
1048
+ };
1049
+
1050
+ SpecView.prototype.updatePending = function(spec, elapsed) {
1051
+ return this.addStatusClass("pending");
1052
+ };
1053
+
1054
+ SpecView.prototype.updateDisabled = function(spec, elapsed) {};
1055
+
1056
+ SpecView.prototype.clearClasses = function() {
1057
+ return this.el.className = "";
1058
+ };
1059
+
1060
+ SpecView.prototype.addStatusClass = function(status) {
1061
+ return this.addClass("state-" + status);
1062
+ };
1063
+
1064
+ SpecView.prototype.addClass = function(name) {
1065
+ return this.el.className += " " + name;
959
1066
  };
960
1067
 
961
1068
  return SpecView;
@@ -1091,52 +1198,45 @@
1091
1198
  var result;
1092
1199
  this.spec = spec1;
1093
1200
  result = this.spec.result();
1094
- if (result.skipped) {
1095
- return;
1201
+ if (result.status === "pending") {
1202
+ return this.trackPending(this.spec);
1203
+ } else if (result.status === "failed") {
1204
+ return this.trackFailed(this.spec);
1205
+ } else if (result.skipped) {
1206
+ return this.trackDisabled(this.spec);
1207
+ } else {
1208
+ return this.trackPassed(this.spec);
1096
1209
  }
1097
- this.reportSuites();
1098
- switch (result.status) {
1099
- case "pending":
1100
- return this.trackPending();
1101
- case "failed":
1102
- return this.trackFailure();
1103
- default:
1104
- return this.log({
1105
- type: "spec",
1106
- suite: this.spec.suiteName,
1107
- label: this.spec.description,
1108
- status: result.status,
1109
- skipped: result.skipped
1110
- });
1111
- }
1112
- };
1113
-
1114
- Console.prototype.trackPending = function() {
1210
+ };
1211
+
1212
+ Console.prototype.trackPending = function(spec) {
1115
1213
  var result;
1116
- result = this.spec.result();
1214
+ this.reportSuites();
1215
+ result = spec.result();
1117
1216
  return this.log({
1118
1217
  type: "spec",
1119
- suite: this.spec.suiteName,
1120
- label: this.spec.description,
1218
+ suite: spec.suiteName,
1219
+ label: spec.description,
1121
1220
  status: result.status,
1122
1221
  skipped: result.skipped
1123
1222
  });
1124
1223
  };
1125
1224
 
1126
- Console.prototype.trackFailure = function() {
1225
+ Console.prototype.trackFailed = function(spec) {
1127
1226
  var error, i, len, ref, result, results;
1128
- result = this.spec.result();
1129
- ref = this.spec.errors();
1227
+ this.reportSuites();
1228
+ result = spec.result();
1229
+ ref = spec.errors();
1130
1230
  results = [];
1131
1231
  for (i = 0, len = ref.length; i < len; i++) {
1132
1232
  error = ref[i];
1133
1233
  results.push(this.log({
1134
1234
  type: "spec",
1135
- suite: this.spec.suiteName,
1136
- label: this.spec.description,
1235
+ suite: spec.suiteName,
1236
+ label: spec.description,
1137
1237
  status: result.status,
1138
1238
  skipped: result.skipped,
1139
- link: this.spec.fullDescription,
1239
+ link: spec.fullDescription,
1140
1240
  message: error.message,
1141
1241
  trace: error.stack || error.message || "Stack Trace Unavailable"
1142
1242
  }));
@@ -1144,6 +1244,20 @@
1144
1244
  return results;
1145
1245
  };
1146
1246
 
1247
+ Console.prototype.trackDisabled = function(spec) {};
1248
+
1249
+ Console.prototype.trackPassed = function(spec, result) {
1250
+ this.reportSuites();
1251
+ result = spec.result();
1252
+ return this.log({
1253
+ type: "spec",
1254
+ suite: spec.suiteName,
1255
+ label: spec.description,
1256
+ status: result.status,
1257
+ skipped: result.skipped
1258
+ });
1259
+ };
1260
+
1147
1261
  Console.prototype.log = function(obj) {
1148
1262
  if (obj == null) {
1149
1263
  obj = {};
@@ -1362,12 +1476,17 @@
1362
1476
 
1363
1477
  }).call(this);
1364
1478
  (function() {
1365
- Teaspoon.Mocha.Spec = (function() {
1479
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1480
+ hasProp = {}.hasOwnProperty;
1481
+
1482
+ Teaspoon.Mocha.Spec = (function(superClass) {
1483
+ extend(Spec, superClass);
1484
+
1366
1485
  function Spec(spec) {
1367
1486
  this.spec = spec;
1368
1487
  this.fullDescription = this.spec.fullTitle();
1369
1488
  this.description = this.spec.title;
1370
- this.link = "?grep=" + (encodeURIComponent(this.fullDescription));
1489
+ this.link = this.filterUrl(this.fullDescription);
1371
1490
  this.parent = this.spec.parent;
1372
1491
  this.suiteName = this.parent.fullTitle();
1373
1492
  this.viewId = this.spec.viewId;
@@ -1407,29 +1526,34 @@
1407
1526
  }
1408
1527
  return {
1409
1528
  status: status,
1410
- skipped: this.spec.state === "skipped"
1529
+ skipped: this.spec.state === "skipped" || this.pending
1411
1530
  };
1412
1531
  };
1413
1532
 
1414
1533
  return Spec;
1415
1534
 
1416
- })();
1535
+ })(Teaspoon.Spec);
1417
1536
 
1418
1537
  }).call(this);
1419
1538
  (function() {
1420
- Teaspoon.Mocha.Suite = (function() {
1539
+ var extend = function(child, parent) { for (var key in parent) { if (hasProp.call(parent, key)) child[key] = parent[key]; } function ctor() { this.constructor = child; } ctor.prototype = parent.prototype; child.prototype = new ctor(); child.__super__ = parent.prototype; return child; },
1540
+ hasProp = {}.hasOwnProperty;
1541
+
1542
+ Teaspoon.Mocha.Suite = (function(superClass) {
1543
+ extend(Suite, superClass);
1544
+
1421
1545
  function Suite(suite) {
1422
1546
  var ref;
1423
1547
  this.suite = suite;
1424
1548
  this.fullDescription = this.suite.fullTitle();
1425
1549
  this.description = this.suite.title;
1426
- this.link = "?grep=" + (encodeURIComponent(this.fullDescription));
1550
+ this.link = this.filterUrl(this.fullDescription);
1427
1551
  this.parent = ((ref = this.suite.parent) != null ? ref.root : void 0) ? null : this.suite.parent;
1428
1552
  this.viewId = this.suite.viewId;
1429
1553
  }
1430
1554
 
1431
1555
  return Suite;
1432
1556
 
1433
- })();
1557
+ })(Teaspoon.Suite);
1434
1558
 
1435
1559
  }).call(this);