newjs 1.3.6 → 1.3.7

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.
@@ -1,3 +1,7 @@
1
+ == 1.3.7 2008-03-04
2
+
3
+ * Update to jsunittest 0.6.3 with IE6/7 fixes
4
+
1
5
  == 1.3.6 2008-02-21
2
6
 
3
7
  * rails/javascript_test: mounts public/javascripts not src
@@ -1,4 +1,4 @@
1
- /* Jsunittest, version 0.6.1
1
+ /* Jsunittest, version 0.6.3
2
2
  * (c) 2008 Dr Nic Williams
3
3
  *
4
4
  * Jsunittest is freely distributable under
@@ -8,10 +8,6 @@
8
8
  *--------------------------------------------------------------------------*/
9
9
 
10
10
  var JsUnitTest = {
11
- Version: '0.6.1',
12
- };
13
-
14
- var DrNicTest = {
15
11
  Unit: {},
16
12
  inspect: function(object) {
17
13
  try {
@@ -49,7 +45,7 @@ var DrNicTest = {
49
45
  while (source.length > 0) {
50
46
  if (match = source.match(pattern)) {
51
47
  result += source.slice(0, match.index);
52
- result += DrNicTest.String.interpret(replacement(match));
48
+ result += JsUnitTest.String.interpret(replacement(match));
53
49
  source = source.slice(match.index + match[0].length);
54
50
  } else {
55
51
  result += source, source = '';
@@ -197,22 +193,24 @@ var DrNicTest = {
197
193
  }
198
194
  };
199
195
 
200
- DrNicTest.gsub.prepareReplacement = function(replacement) {
196
+ JsUnitTest.gsub.prepareReplacement = function(replacement) {
201
197
  if (typeof replacement == "function") return replacement;
202
198
  var template = new Template(replacement);
203
199
  return function(match) { return template.evaluate(match) };
204
200
  };
205
201
 
206
- DrNicTest.Template = function(template, pattern) {
202
+ JsUnitTest.Version = '0.6.3';
203
+
204
+ JsUnitTest.Template = function(template, pattern) {
207
205
  this.template = template; //template.toString();
208
- this.pattern = pattern || DrNicTest.Template.Pattern;
206
+ this.pattern = pattern || JsUnitTest.Template.Pattern;
209
207
  };
210
208
 
211
- DrNicTest.Template.prototype.evaluate = function(object) {
209
+ JsUnitTest.Template.prototype.evaluate = function(object) {
212
210
  if (typeof object.toTemplateReplacements == "function")
213
211
  object = object.toTemplateReplacements();
214
212
 
215
- return DrNicTest.gsub(this.template, this.pattern, function(match) {
213
+ return JsUnitTest.gsub(this.template, this.pattern, function(match) {
216
214
  if (object == null) return '';
217
215
 
218
216
  var before = match[1] || '';
@@ -231,24 +229,24 @@ DrNicTest.Template.prototype.evaluate = function(object) {
231
229
  match = pattern.exec(expr);
232
230
  }
233
231
 
234
- return before + DrNicTest.String.interpret(ctx);
232
+ return before + JsUnitTest.String.interpret(ctx);
235
233
  });
236
234
  }
237
235
 
238
- DrNicTest.Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
239
- DrNicTest.Event = {};
236
+ JsUnitTest.Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
237
+ JsUnitTest.Event = {};
240
238
  // written by Dean Edwards, 2005
241
239
  // with input from Tino Zijdel, Matthias Miller, Diego Perini
242
240
  // namespaced by Dr Nic Williams 2008
243
241
 
244
242
  // http://dean.edwards.name/weblog/2005/10/add-event/
245
243
  // http://dean.edwards.name/weblog/2005/10/add-event2/
246
- DrNicTest.Event.addEvent = function(element, type, handler) {
244
+ JsUnitTest.Event.addEvent = function(element, type, handler) {
247
245
  if (element.addEventListener) {
248
246
  element.addEventListener(type, handler, false);
249
247
  } else {
250
248
  // assign each event handler a unique ID
251
- if (!handler.$$guid) handler.$$guid = addEvent.guid++;
249
+ if (!handler.$$guid) handler.$$guid = JsUnitTest.Event.addEvent.guid++;
252
250
  // create a hash table of event types for the element
253
251
  if (!element.events) element.events = {};
254
252
  // create a hash table of event handlers for each element/event pair
@@ -263,13 +261,13 @@ DrNicTest.Event.addEvent = function(element, type, handler) {
263
261
  // store the event handler in the hash table
264
262
  handlers[handler.$$guid] = handler;
265
263
  // assign a global event handler to do all the work
266
- element["on" + type] = handleEvent;
264
+ element["on" + type] = this.handleEvent;
267
265
  }
268
266
  };
269
267
  // a counter used to create unique IDs
270
- DrNicTest.Event.addEvent.guid = 1;
268
+ JsUnitTest.Event.addEvent.guid = 1;
271
269
 
272
- DrNicTest.Event.removeEvent = function(element, type, handler) {
270
+ JsUnitTest.Event.removeEvent = function(element, type, handler) {
273
271
  if (element.removeEventListener) {
274
272
  element.removeEventListener(type, handler, false);
275
273
  } else {
@@ -280,10 +278,10 @@ DrNicTest.Event.removeEvent = function(element, type, handler) {
280
278
  }
281
279
  };
282
280
 
283
- DrNicTest.Event.handleEvent = function(event) {
281
+ JsUnitTest.Event.handleEvent = function(event) {
284
282
  var returnValue = true;
285
283
  // grab the event object (IE uses a global event object)
286
- event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
284
+ event = event || JsUnitTest.Event.fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
287
285
  // get a reference to the hash table of event handlers
288
286
  var handlers = this.events[event.type];
289
287
  // execute each event handler
@@ -296,67 +294,81 @@ DrNicTest.Event.handleEvent = function(event) {
296
294
  return returnValue;
297
295
  };
298
296
 
299
- DrNicTest.Event.fixEvent = function(event) {
297
+ JsUnitTest.Event.fixEvent = function(event) {
300
298
  // add W3C standard event methods
301
- event.preventDefault = fixEvent.preventDefault;
302
- event.stopPropagation = fixEvent.stopPropagation;
299
+ event.preventDefault = this.fixEvent.preventDefault;
300
+ event.stopPropagation = this.fixEvent.stopPropagation;
303
301
  return event;
304
302
  };
305
- DrNicTest.Event.fixEvent.preventDefault = function() {
303
+ JsUnitTest.Event.fixEvent.preventDefault = function() {
306
304
  this.returnValue = false;
307
305
  };
308
- DrNicTest.Event.fixEvent.stopPropagation = function() {
306
+ JsUnitTest.Event.fixEvent.stopPropagation = function() {
309
307
  this.cancelBubble = true;
310
308
  };
311
309
 
312
- DrNicTest.Unit.Logger = function(element) {
313
- this.element = DrNicTest.$(element);
310
+ JsUnitTest.Unit.Logger = function(element) {
311
+ this.element = JsUnitTest.$(element);
314
312
  if (this.element) this._createLogTable();
315
313
  };
316
314
 
317
- DrNicTest.Unit.Logger.prototype.start = function(testName) {
315
+ JsUnitTest.Unit.Logger.prototype.start = function(testName) {
318
316
  if (!this.element) return;
319
317
  var tbody = this.element.getElementsByTagName('tbody')[0];
320
- tbody.innerHTML = tbody.innerHTML + '<tr><td>' + testName + '</td><td></td><td></td></tr>';
318
+
319
+ var tr = document.createElement('tr');
320
+ var td;
321
+
322
+ //testname
323
+ td = document.createElement('td');
324
+ td.appendChild(document.createTextNode(testName));
325
+ tr.appendChild(td)
326
+
327
+ tr.appendChild(document.createElement('td'));//status
328
+ tr.appendChild(document.createElement('td'));//message
329
+
330
+ tbody.appendChild(tr);
321
331
  };
322
332
 
323
- DrNicTest.Unit.Logger.prototype.setStatus = function(status) {
333
+ JsUnitTest.Unit.Logger.prototype.setStatus = function(status) {
324
334
  var logline = this.getLastLogLine();
325
335
  logline.className = status;
326
336
  var statusCell = logline.getElementsByTagName('td')[1];
327
- statusCell.innerHTML = status;
337
+ statusCell.appendChild(document.createTextNode(status));
328
338
  };
329
339
 
330
- DrNicTest.Unit.Logger.prototype.finish = function(status, summary) {
340
+ JsUnitTest.Unit.Logger.prototype.finish = function(status, summary) {
331
341
  if (!this.element) return;
332
342
  this.setStatus(status);
333
343
  this.message(summary);
334
344
  };
335
345
 
336
- DrNicTest.Unit.Logger.prototype.message = function(message) {
346
+ JsUnitTest.Unit.Logger.prototype.message = function(message) {
337
347
  if (!this.element) return;
338
348
  var cell = this.getMessageCell();
349
+
350
+ // cell.appendChild(document.createTextNode(this._toHTML(message)));
339
351
  cell.innerHTML = this._toHTML(message);
340
352
  };
341
353
 
342
- DrNicTest.Unit.Logger.prototype.summary = function(summary) {
354
+ JsUnitTest.Unit.Logger.prototype.summary = function(summary) {
343
355
  if (!this.element) return;
344
356
  var div = this.element.getElementsByTagName('div')[0];
345
357
  div.innerHTML = this._toHTML(summary);
346
358
  };
347
359
 
348
- DrNicTest.Unit.Logger.prototype.getLastLogLine = function() {
360
+ JsUnitTest.Unit.Logger.prototype.getLastLogLine = function() {
349
361
  var tbody = this.element.getElementsByTagName('tbody')[0];
350
362
  var loglines = tbody.getElementsByTagName('tr');
351
363
  return loglines[loglines.length - 1];
352
364
  };
353
365
 
354
- DrNicTest.Unit.Logger.prototype.getMessageCell = function() {
366
+ JsUnitTest.Unit.Logger.prototype.getMessageCell = function() {
355
367
  var logline = this.getLastLogLine();
356
368
  return logline.getElementsByTagName('td')[2];
357
369
  };
358
370
 
359
- DrNicTest.Unit.Logger.prototype._createLogTable = function() {
371
+ JsUnitTest.Unit.Logger.prototype._createLogTable = function() {
360
372
  var html = '<div class="logsummary">running...</div>' +
361
373
  '<table class="logtable">' +
362
374
  '<thead><tr><th>Status</th><th>Test</th><th>Message</th></tr></thead>' +
@@ -365,7 +377,7 @@ DrNicTest.Unit.Logger.prototype._createLogTable = function() {
365
377
  this.element.innerHTML = html;
366
378
  };
367
379
 
368
- DrNicTest.Unit.Logger.prototype.appendActionButtons = function(actions) {
380
+ JsUnitTest.Unit.Logger.prototype.appendActionButtons = function(actions) {
369
381
  // actions = $H(actions);
370
382
  // if (!actions.any()) return;
371
383
  // var div = new Element("div", {className: 'action_buttons'});
@@ -377,22 +389,22 @@ DrNicTest.Unit.Logger.prototype.appendActionButtons = function(actions) {
377
389
  // this.getMessageCell().insert(div);
378
390
  };
379
391
 
380
- DrNicTest.Unit.Logger.prototype._toHTML = function(txt) {
381
- return DrNicTest.escapeHTML(txt).replace(/\n/g,"<br/>");
392
+ JsUnitTest.Unit.Logger.prototype._toHTML = function(txt) {
393
+ return JsUnitTest.escapeHTML(txt).replace(/\n/g,"<br/>");
382
394
  };
383
- DrNicTest.Unit.MessageTemplate = function(string) {
395
+ JsUnitTest.Unit.MessageTemplate = function(string) {
384
396
  var parts = [];
385
- var str = DrNicTest.scan((string || ''), /(?=[^\\])\?|(?:\\\?|[^\?])+/, function(part) {
397
+ var str = JsUnitTest.scan((string || ''), /(?=[^\\])\?|(?:\\\?|[^\?])+/, function(part) {
386
398
  parts.push(part[0]);
387
399
  });
388
400
  this.parts = parts;
389
401
  };
390
402
 
391
- DrNicTest.Unit.MessageTemplate.prototype.evaluate = function(params) {
403
+ JsUnitTest.Unit.MessageTemplate.prototype.evaluate = function(params) {
392
404
  var results = [];
393
405
  for (var i=0; i < this.parts.length; i++) {
394
406
  var part = this.parts[i];
395
- var result = (part == '?') ? DrNicTest.inspect(params.shift()) : part.replace(/\\\?/, '?');
407
+ var result = (part == '?') ? JsUnitTest.inspect(params.shift()) : part.replace(/\\\?/, '?');
396
408
  results.push(result);
397
409
  };
398
410
  return results.join('');
@@ -402,7 +414,7 @@ DrNicTest.Unit.MessageTemplate.prototype.evaluate = function(params) {
402
414
  // All of which are outline in the comments, below
403
415
  // From John Resig's book Pro JavaScript Techniques
404
416
  // published by Apress, 2006-8
405
- DrNicTest.ajax = function( options ) {
417
+ JsUnitTest.ajax = function( options ) {
406
418
 
407
419
  // Load the options object with defaults, if no
408
420
  // values were provided by the user
@@ -518,11 +530,11 @@ DrNicTest.ajax = function( options ) {
518
530
  }
519
531
 
520
532
  }
521
- DrNicTest.Unit.Assertions = {
533
+ JsUnitTest.Unit.Assertions = {
522
534
  buildMessage: function(message, template) {
523
- var args = DrNicTest.arrayfromargs(arguments).slice(2);
535
+ var args = JsUnitTest.arrayfromargs(arguments).slice(2);
524
536
  return (message ? message + '\n' : '') +
525
- new DrNicTest.Unit.MessageTemplate(template).evaluate(args);
537
+ new JsUnitTest.Unit.MessageTemplate(template).evaluate(args);
526
538
  },
527
539
 
528
540
  flunk: function(message) {
@@ -552,8 +564,8 @@ DrNicTest.Unit.Assertions = {
552
564
 
553
565
  assertEnumEqual: function(expected, actual, message) {
554
566
  message = this.buildMessage(message || 'assertEnumEqual', 'expected <?>, actual: <?>', expected, actual);
555
- var expected_array = DrNicTest.flattenArray(expected);
556
- var actual_array = DrNicTest.flattenArray(actual);
567
+ var expected_array = JsUnitTest.flattenArray(expected);
568
+ var actual_array = JsUnitTest.flattenArray(actual);
557
569
  this.assertBlock(message, function() {
558
570
  if (expected_array.length == actual_array.length) {
559
571
  for (var i=0; i < expected_array.length; i++) {
@@ -567,8 +579,8 @@ DrNicTest.Unit.Assertions = {
567
579
 
568
580
  assertEnumNotEqual: function(expected, actual, message) {
569
581
  message = this.buildMessage(message || 'assertEnumNotEqual', '<?> was the same as <?>', expected, actual);
570
- var expected_array = DrNicTest.flattenArray(expected);
571
- var actual_array = DrNicTest.flattenArray(actual);
582
+ var expected_array = JsUnitTest.flattenArray(expected);
583
+ var actual_array = JsUnitTest.flattenArray(actual);
572
584
  this.assertBlock(message, function() {
573
585
  if (expected_array.length == actual_array.length) {
574
586
  for (var i=0; i < expected_array.length; i++) {
@@ -582,8 +594,8 @@ DrNicTest.Unit.Assertions = {
582
594
 
583
595
  assertHashEqual: function(expected, actual, message) {
584
596
  message = this.buildMessage(message || 'assertHashEqual', 'expected <?>, actual: <?>', expected, actual);
585
- var expected_array = DrNicTest.flattenArray(DrNicTest.hashToSortedArray(expected));
586
- var actual_array = DrNicTest.flattenArray(DrNicTest.hashToSortedArray(actual));
597
+ var expected_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(expected));
598
+ var actual_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(actual));
587
599
  var block = function() {
588
600
  if (expected_array.length == actual_array.length) {
589
601
  for (var i=0; i < expected_array.length; i++) {
@@ -598,8 +610,8 @@ DrNicTest.Unit.Assertions = {
598
610
 
599
611
  assertHashNotEqual: function(expected, actual, message) {
600
612
  message = this.buildMessage(message || 'assertHashNotEqual', '<?> was the same as <?>', expected, actual);
601
- var expected_array = DrNicTest.flattenArray(DrNicTest.hashToSortedArray(expected));
602
- var actual_array = DrNicTest.flattenArray(DrNicTest.hashToSortedArray(actual));
613
+ var expected_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(expected));
614
+ var actual_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(actual));
603
615
  // from now we recursively zip & compare nested arrays
604
616
  var block = function() {
605
617
  if (expected_array.length == actual_array.length) {
@@ -665,7 +677,7 @@ DrNicTest.Unit.Assertions = {
665
677
 
666
678
  assertHidden: function(element, message) {
667
679
  message = this.buildMessage(message || 'assertHidden', '? isn\'t hidden.', element);
668
- this.assertBlock(message, function() { return element.style.display == 'none' });
680
+ this.assertBlock(message, function() { return !element.style.display || element.style.display == 'none' });
669
681
  },
670
682
 
671
683
  assertInstanceOf: function(expected, actual, message) {
@@ -708,10 +720,10 @@ DrNicTest.Unit.Assertions = {
708
720
  },
709
721
 
710
722
  _isVisible: function(element) {
711
- element = DrNicTest.$(element);
723
+ element = JsUnitTest.$(element);
712
724
  if(!element.parentNode) return true;
713
725
  this.assertNotNull(element);
714
- if(element.style && element.style.display == 'none')
726
+ if(element.style && (element.style.display == 'none'))
715
727
  return false;
716
728
 
717
729
  return arguments.callee.call(this, element.parentNode);
@@ -728,7 +740,7 @@ DrNicTest.Unit.Assertions = {
728
740
  },
729
741
 
730
742
  assertElementsMatch: function() {
731
- var pass = true, expressions = DrNicTest.arrayfromargs(arguments);
743
+ var pass = true, expressions = JsUnitTest.arrayfromargs(arguments);
732
744
  var elements = expressions.shift();
733
745
  if (elements.length != expressions.length) {
734
746
  message = this.buildMessage('assertElementsMatch', 'size mismatch: ? elements, ? expressions (?).', elements.length, expressions.length, expressions);
@@ -737,8 +749,8 @@ DrNicTest.Unit.Assertions = {
737
749
  }
738
750
  for (var i=0; i < expressions.length; i++) {
739
751
  var expression = expressions[i];
740
- var element = DrNicTest.$(elements[i]);
741
- if (DrNicTest.selectorMatch(expression, element)) {
752
+ var element = JsUnitTest.$(elements[i]);
753
+ if (JsUnitTest.selectorMatch(expression, element)) {
742
754
  pass = true;
743
755
  break;
744
756
  }
@@ -753,28 +765,28 @@ DrNicTest.Unit.Assertions = {
753
765
  this.assertElementsMatch([element], expression);
754
766
  }
755
767
  };
756
- DrNicTest.Unit.Runner = function(testcases) {
768
+ JsUnitTest.Unit.Runner = function(testcases) {
757
769
  var argumentOptions = arguments[1] || {};
758
770
  var options = this.options = {};
759
771
  options.testLog = ('testLog' in argumentOptions) ? argumentOptions.testLog : 'testlog';
760
772
  options.resultsURL = this.queryParams.resultsURL;
761
- options.testLog = DrNicTest.$(options.testLog);
773
+ options.testLog = JsUnitTest.$(options.testLog);
762
774
 
763
775
  this.tests = this.getTests(testcases);
764
776
  this.currentTest = 0;
765
- this.logger = new DrNicTest.Unit.Logger(options.testLog);
777
+ this.logger = new JsUnitTest.Unit.Logger(options.testLog);
766
778
 
767
779
  var self = this;
768
- DrNicTest.Event.addEvent(window, "load", function() {
780
+ JsUnitTest.Event.addEvent(window, "load", function() {
769
781
  setTimeout(function() {
770
782
  self.runTests();
771
783
  }, 0.1);
772
784
  });
773
785
  };
774
786
 
775
- DrNicTest.Unit.Runner.prototype.queryParams = DrNicTest.toQueryParams();
787
+ JsUnitTest.Unit.Runner.prototype.queryParams = JsUnitTest.toQueryParams();
776
788
 
777
- DrNicTest.Unit.Runner.prototype.portNumber = function() {
789
+ JsUnitTest.Unit.Runner.prototype.portNumber = function() {
778
790
  if (window.location.search.length > 0) {
779
791
  var matches = window.location.search.match(/\:(\d{3,5})\//);
780
792
  if (matches) {
@@ -784,7 +796,7 @@ DrNicTest.Unit.Runner.prototype.portNumber = function() {
784
796
  return null;
785
797
  };
786
798
 
787
- DrNicTest.Unit.Runner.prototype.getTests = function(testcases) {
799
+ JsUnitTest.Unit.Runner.prototype.getTests = function(testcases) {
788
800
  var tests = [], options = this.options;
789
801
  if (this.queryParams.tests) tests = this.queryParams.tests.split(',');
790
802
  else if (options.tests) tests = options.tests;
@@ -799,13 +811,13 @@ DrNicTest.Unit.Runner.prototype.getTests = function(testcases) {
799
811
  var test = tests[i];
800
812
  if (testcases[test])
801
813
  results.push(
802
- new DrNicTest.Unit.Testcase(test, testcases[test], testcases.setup, testcases.teardown)
814
+ new JsUnitTest.Unit.Testcase(test, testcases[test], testcases.setup, testcases.teardown)
803
815
  );
804
816
  };
805
817
  return results;
806
818
  };
807
819
 
808
- DrNicTest.Unit.Runner.prototype.getResult = function() {
820
+ JsUnitTest.Unit.Runner.prototype.getResult = function() {
809
821
  var results = {
810
822
  tests: this.tests.length,
811
823
  assertions: 0,
@@ -822,7 +834,7 @@ DrNicTest.Unit.Runner.prototype.getResult = function() {
822
834
  return results;
823
835
  };
824
836
 
825
- DrNicTest.Unit.Runner.prototype.postResults = function() {
837
+ JsUnitTest.Unit.Runner.prototype.postResults = function() {
826
838
  if (this.options.resultsURL) {
827
839
  // new Ajax.Request(this.options.resultsURL,
828
840
  // { method: 'get', parameters: this.getResult(), asynchronous: false });
@@ -831,14 +843,14 @@ DrNicTest.Unit.Runner.prototype.postResults = function() {
831
843
  url += "assertions="+ results.assertions + "&";
832
844
  url += "failures=" + results.failures + "&";
833
845
  url += "errors=" + results.errors;
834
- DrNicTest.ajax({
846
+ JsUnitTest.ajax({
835
847
  url: url,
836
848
  type: 'GET'
837
849
  })
838
850
  }
839
851
  };
840
852
 
841
- DrNicTest.Unit.Runner.prototype.runTests = function() {
853
+ JsUnitTest.Unit.Runner.prototype.runTests = function() {
842
854
  var test = this.tests[this.currentTest], actions;
843
855
 
844
856
  if (!test) return this.finish();
@@ -861,15 +873,15 @@ DrNicTest.Unit.Runner.prototype.runTests = function() {
861
873
  this.runTests();
862
874
  };
863
875
 
864
- DrNicTest.Unit.Runner.prototype.finish = function() {
876
+ JsUnitTest.Unit.Runner.prototype.finish = function() {
865
877
  this.postResults();
866
878
  this.logger.summary(this.summary());
867
879
  };
868
880
 
869
- DrNicTest.Unit.Runner.prototype.summary = function() {
870
- return new DrNicTest.Template('#{tests} tests, #{assertions} assertions, #{failures} failures, #{errors} errors').evaluate(this.getResult());
881
+ JsUnitTest.Unit.Runner.prototype.summary = function() {
882
+ return new JsUnitTest.Template('#{tests} tests, #{assertions} assertions, #{failures} failures, #{errors} errors').evaluate(this.getResult());
871
883
  };
872
- DrNicTest.Unit.Testcase = function(name, test, setup, teardown) {
884
+ JsUnitTest.Unit.Testcase = function(name, test, setup, teardown) {
873
885
  this.name = name;
874
886
  this.test = test || function() {};
875
887
  this.setup = setup || function() {};
@@ -877,27 +889,27 @@ DrNicTest.Unit.Testcase = function(name, test, setup, teardown) {
877
889
  this.messages = [];
878
890
  this.actions = {};
879
891
  };
880
- // import DrNicTest.Unit.Assertions
892
+ // import JsUnitTest.Unit.Assertions
881
893
 
882
- for (method in DrNicTest.Unit.Assertions) {
883
- DrNicTest.Unit.Testcase.prototype[method] = DrNicTest.Unit.Assertions[method];
894
+ for (method in JsUnitTest.Unit.Assertions) {
895
+ JsUnitTest.Unit.Testcase.prototype[method] = JsUnitTest.Unit.Assertions[method];
884
896
  }
885
897
 
886
- DrNicTest.Unit.Testcase.prototype.isWaiting = false;
887
- DrNicTest.Unit.Testcase.prototype.timeToWait = 1000;
888
- DrNicTest.Unit.Testcase.prototype.assertions = 0;
889
- DrNicTest.Unit.Testcase.prototype.failures = 0;
890
- DrNicTest.Unit.Testcase.prototype.errors = 0;
891
- // DrNicTest.Unit.Testcase.prototype.isRunningFromRake = window.location.port == 4711;
892
- DrNicTest.Unit.Testcase.prototype.isRunningFromRake = window.location.port;
898
+ JsUnitTest.Unit.Testcase.prototype.isWaiting = false;
899
+ JsUnitTest.Unit.Testcase.prototype.timeToWait = 1000;
900
+ JsUnitTest.Unit.Testcase.prototype.assertions = 0;
901
+ JsUnitTest.Unit.Testcase.prototype.failures = 0;
902
+ JsUnitTest.Unit.Testcase.prototype.errors = 0;
903
+ // JsUnitTest.Unit.Testcase.prototype.isRunningFromRake = window.location.port == 4711;
904
+ JsUnitTest.Unit.Testcase.prototype.isRunningFromRake = window.location.port;
893
905
 
894
- DrNicTest.Unit.Testcase.prototype.wait = function(time, nextPart) {
906
+ JsUnitTest.Unit.Testcase.prototype.wait = function(time, nextPart) {
895
907
  this.isWaiting = true;
896
908
  this.test = nextPart;
897
909
  this.timeToWait = time;
898
910
  };
899
911
 
900
- DrNicTest.Unit.Testcase.prototype.run = function(rethrow) {
912
+ JsUnitTest.Unit.Testcase.prototype.run = function(rethrow) {
901
913
  try {
902
914
  try {
903
915
  if (!this.isWaiting) this.setup();
@@ -915,17 +927,17 @@ DrNicTest.Unit.Testcase.prototype.run = function(rethrow) {
915
927
  }
916
928
  };
917
929
 
918
- DrNicTest.Unit.Testcase.prototype.summary = function() {
930
+ JsUnitTest.Unit.Testcase.prototype.summary = function() {
919
931
  var msg = '#{assertions} assertions, #{failures} failures, #{errors} errors\n';
920
- return new DrNicTest.Template(msg).evaluate(this) +
932
+ return new JsUnitTest.Template(msg).evaluate(this) +
921
933
  this.messages.join("\n");
922
934
  };
923
935
 
924
- DrNicTest.Unit.Testcase.prototype.pass = function() {
936
+ JsUnitTest.Unit.Testcase.prototype.pass = function() {
925
937
  this.assertions++;
926
938
  };
927
939
 
928
- DrNicTest.Unit.Testcase.prototype.fail = function(message) {
940
+ JsUnitTest.Unit.Testcase.prototype.fail = function(message) {
929
941
  this.failures++;
930
942
  var line = "";
931
943
  try {
@@ -936,23 +948,23 @@ DrNicTest.Unit.Testcase.prototype.fail = function(message) {
936
948
  this.messages.push("Failure: " + message + (line ? " Line #" + line : ""));
937
949
  };
938
950
 
939
- DrNicTest.Unit.Testcase.prototype.info = function(message) {
951
+ JsUnitTest.Unit.Testcase.prototype.info = function(message) {
940
952
  this.messages.push("Info: " + message);
941
953
  };
942
954
 
943
- DrNicTest.Unit.Testcase.prototype.error = function(error, test) {
955
+ JsUnitTest.Unit.Testcase.prototype.error = function(error, test) {
944
956
  this.errors++;
945
957
  this.actions['retry with throw'] = function() { test.run(true) };
946
- this.messages.push(error.name + ": "+ error.message + "(" + DrNicTest.inspect(error) + ")");
958
+ this.messages.push(error.name + ": "+ error.message + "(" + JsUnitTest.inspect(error) + ")");
947
959
  };
948
960
 
949
- DrNicTest.Unit.Testcase.prototype.status = function() {
961
+ JsUnitTest.Unit.Testcase.prototype.status = function() {
950
962
  if (this.failures > 0) return 'failed';
951
963
  if (this.errors > 0) return 'error';
952
964
  return 'passed';
953
965
  };
954
966
 
955
- DrNicTest.Unit.Testcase.prototype.benchmark = function(operation, iterations) {
967
+ JsUnitTest.Unit.Testcase.prototype.benchmark = function(operation, iterations) {
956
968
  var startAt = new Date();
957
969
  (iterations || 1).times(operation);
958
970
  var timeTaken = ((new Date())-startAt);
@@ -961,4 +973,4 @@ DrNicTest.Unit.Testcase.prototype.benchmark = function(operation, iterations) {
961
973
  return timeTaken;
962
974
  };
963
975
 
964
- Test = DrNicTest
976
+ Test = JsUnitTest
@@ -2,7 +2,7 @@ module Newjs #:nodoc:
2
2
  module VERSION #:nodoc:
3
3
  MAJOR = 1
4
4
  MINOR = 3
5
- TINY = 6
5
+ TINY = 7
6
6
 
7
7
  STRING = [MAJOR, MINOR, TINY].join('.')
8
8
  end
@@ -1,4 +1,4 @@
1
- /* Jsunittest, version 0.6.1
1
+ /* Jsunittest, version 0.6.3
2
2
  * (c) 2008 Dr Nic Williams
3
3
  *
4
4
  * Jsunittest is freely distributable under
@@ -8,10 +8,6 @@
8
8
  *--------------------------------------------------------------------------*/
9
9
 
10
10
  var JsUnitTest = {
11
- Version: '0.6.1',
12
- };
13
-
14
- var DrNicTest = {
15
11
  Unit: {},
16
12
  inspect: function(object) {
17
13
  try {
@@ -49,7 +45,7 @@ var DrNicTest = {
49
45
  while (source.length > 0) {
50
46
  if (match = source.match(pattern)) {
51
47
  result += source.slice(0, match.index);
52
- result += DrNicTest.String.interpret(replacement(match));
48
+ result += JsUnitTest.String.interpret(replacement(match));
53
49
  source = source.slice(match.index + match[0].length);
54
50
  } else {
55
51
  result += source, source = '';
@@ -197,22 +193,24 @@ var DrNicTest = {
197
193
  }
198
194
  };
199
195
 
200
- DrNicTest.gsub.prepareReplacement = function(replacement) {
196
+ JsUnitTest.gsub.prepareReplacement = function(replacement) {
201
197
  if (typeof replacement == "function") return replacement;
202
198
  var template = new Template(replacement);
203
199
  return function(match) { return template.evaluate(match) };
204
200
  };
205
201
 
206
- DrNicTest.Template = function(template, pattern) {
202
+ JsUnitTest.Version = '0.6.3';
203
+
204
+ JsUnitTest.Template = function(template, pattern) {
207
205
  this.template = template; //template.toString();
208
- this.pattern = pattern || DrNicTest.Template.Pattern;
206
+ this.pattern = pattern || JsUnitTest.Template.Pattern;
209
207
  };
210
208
 
211
- DrNicTest.Template.prototype.evaluate = function(object) {
209
+ JsUnitTest.Template.prototype.evaluate = function(object) {
212
210
  if (typeof object.toTemplateReplacements == "function")
213
211
  object = object.toTemplateReplacements();
214
212
 
215
- return DrNicTest.gsub(this.template, this.pattern, function(match) {
213
+ return JsUnitTest.gsub(this.template, this.pattern, function(match) {
216
214
  if (object == null) return '';
217
215
 
218
216
  var before = match[1] || '';
@@ -231,24 +229,24 @@ DrNicTest.Template.prototype.evaluate = function(object) {
231
229
  match = pattern.exec(expr);
232
230
  }
233
231
 
234
- return before + DrNicTest.String.interpret(ctx);
232
+ return before + JsUnitTest.String.interpret(ctx);
235
233
  });
236
234
  }
237
235
 
238
- DrNicTest.Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
239
- DrNicTest.Event = {};
236
+ JsUnitTest.Template.Pattern = /(^|.|\r|\n)(#\{(.*?)\})/;
237
+ JsUnitTest.Event = {};
240
238
  // written by Dean Edwards, 2005
241
239
  // with input from Tino Zijdel, Matthias Miller, Diego Perini
242
240
  // namespaced by Dr Nic Williams 2008
243
241
 
244
242
  // http://dean.edwards.name/weblog/2005/10/add-event/
245
243
  // http://dean.edwards.name/weblog/2005/10/add-event2/
246
- DrNicTest.Event.addEvent = function(element, type, handler) {
244
+ JsUnitTest.Event.addEvent = function(element, type, handler) {
247
245
  if (element.addEventListener) {
248
246
  element.addEventListener(type, handler, false);
249
247
  } else {
250
248
  // assign each event handler a unique ID
251
- if (!handler.$$guid) handler.$$guid = addEvent.guid++;
249
+ if (!handler.$$guid) handler.$$guid = JsUnitTest.Event.addEvent.guid++;
252
250
  // create a hash table of event types for the element
253
251
  if (!element.events) element.events = {};
254
252
  // create a hash table of event handlers for each element/event pair
@@ -263,13 +261,13 @@ DrNicTest.Event.addEvent = function(element, type, handler) {
263
261
  // store the event handler in the hash table
264
262
  handlers[handler.$$guid] = handler;
265
263
  // assign a global event handler to do all the work
266
- element["on" + type] = handleEvent;
264
+ element["on" + type] = this.handleEvent;
267
265
  }
268
266
  };
269
267
  // a counter used to create unique IDs
270
- DrNicTest.Event.addEvent.guid = 1;
268
+ JsUnitTest.Event.addEvent.guid = 1;
271
269
 
272
- DrNicTest.Event.removeEvent = function(element, type, handler) {
270
+ JsUnitTest.Event.removeEvent = function(element, type, handler) {
273
271
  if (element.removeEventListener) {
274
272
  element.removeEventListener(type, handler, false);
275
273
  } else {
@@ -280,10 +278,10 @@ DrNicTest.Event.removeEvent = function(element, type, handler) {
280
278
  }
281
279
  };
282
280
 
283
- DrNicTest.Event.handleEvent = function(event) {
281
+ JsUnitTest.Event.handleEvent = function(event) {
284
282
  var returnValue = true;
285
283
  // grab the event object (IE uses a global event object)
286
- event = event || fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
284
+ event = event || JsUnitTest.Event.fixEvent(((this.ownerDocument || this.document || this).parentWindow || window).event);
287
285
  // get a reference to the hash table of event handlers
288
286
  var handlers = this.events[event.type];
289
287
  // execute each event handler
@@ -296,67 +294,81 @@ DrNicTest.Event.handleEvent = function(event) {
296
294
  return returnValue;
297
295
  };
298
296
 
299
- DrNicTest.Event.fixEvent = function(event) {
297
+ JsUnitTest.Event.fixEvent = function(event) {
300
298
  // add W3C standard event methods
301
- event.preventDefault = fixEvent.preventDefault;
302
- event.stopPropagation = fixEvent.stopPropagation;
299
+ event.preventDefault = this.fixEvent.preventDefault;
300
+ event.stopPropagation = this.fixEvent.stopPropagation;
303
301
  return event;
304
302
  };
305
- DrNicTest.Event.fixEvent.preventDefault = function() {
303
+ JsUnitTest.Event.fixEvent.preventDefault = function() {
306
304
  this.returnValue = false;
307
305
  };
308
- DrNicTest.Event.fixEvent.stopPropagation = function() {
306
+ JsUnitTest.Event.fixEvent.stopPropagation = function() {
309
307
  this.cancelBubble = true;
310
308
  };
311
309
 
312
- DrNicTest.Unit.Logger = function(element) {
313
- this.element = DrNicTest.$(element);
310
+ JsUnitTest.Unit.Logger = function(element) {
311
+ this.element = JsUnitTest.$(element);
314
312
  if (this.element) this._createLogTable();
315
313
  };
316
314
 
317
- DrNicTest.Unit.Logger.prototype.start = function(testName) {
315
+ JsUnitTest.Unit.Logger.prototype.start = function(testName) {
318
316
  if (!this.element) return;
319
317
  var tbody = this.element.getElementsByTagName('tbody')[0];
320
- tbody.innerHTML = tbody.innerHTML + '<tr><td>' + testName + '</td><td></td><td></td></tr>';
318
+
319
+ var tr = document.createElement('tr');
320
+ var td;
321
+
322
+ //testname
323
+ td = document.createElement('td');
324
+ td.appendChild(document.createTextNode(testName));
325
+ tr.appendChild(td)
326
+
327
+ tr.appendChild(document.createElement('td'));//status
328
+ tr.appendChild(document.createElement('td'));//message
329
+
330
+ tbody.appendChild(tr);
321
331
  };
322
332
 
323
- DrNicTest.Unit.Logger.prototype.setStatus = function(status) {
333
+ JsUnitTest.Unit.Logger.prototype.setStatus = function(status) {
324
334
  var logline = this.getLastLogLine();
325
335
  logline.className = status;
326
336
  var statusCell = logline.getElementsByTagName('td')[1];
327
- statusCell.innerHTML = status;
337
+ statusCell.appendChild(document.createTextNode(status));
328
338
  };
329
339
 
330
- DrNicTest.Unit.Logger.prototype.finish = function(status, summary) {
340
+ JsUnitTest.Unit.Logger.prototype.finish = function(status, summary) {
331
341
  if (!this.element) return;
332
342
  this.setStatus(status);
333
343
  this.message(summary);
334
344
  };
335
345
 
336
- DrNicTest.Unit.Logger.prototype.message = function(message) {
346
+ JsUnitTest.Unit.Logger.prototype.message = function(message) {
337
347
  if (!this.element) return;
338
348
  var cell = this.getMessageCell();
349
+
350
+ // cell.appendChild(document.createTextNode(this._toHTML(message)));
339
351
  cell.innerHTML = this._toHTML(message);
340
352
  };
341
353
 
342
- DrNicTest.Unit.Logger.prototype.summary = function(summary) {
354
+ JsUnitTest.Unit.Logger.prototype.summary = function(summary) {
343
355
  if (!this.element) return;
344
356
  var div = this.element.getElementsByTagName('div')[0];
345
357
  div.innerHTML = this._toHTML(summary);
346
358
  };
347
359
 
348
- DrNicTest.Unit.Logger.prototype.getLastLogLine = function() {
360
+ JsUnitTest.Unit.Logger.prototype.getLastLogLine = function() {
349
361
  var tbody = this.element.getElementsByTagName('tbody')[0];
350
362
  var loglines = tbody.getElementsByTagName('tr');
351
363
  return loglines[loglines.length - 1];
352
364
  };
353
365
 
354
- DrNicTest.Unit.Logger.prototype.getMessageCell = function() {
366
+ JsUnitTest.Unit.Logger.prototype.getMessageCell = function() {
355
367
  var logline = this.getLastLogLine();
356
368
  return logline.getElementsByTagName('td')[2];
357
369
  };
358
370
 
359
- DrNicTest.Unit.Logger.prototype._createLogTable = function() {
371
+ JsUnitTest.Unit.Logger.prototype._createLogTable = function() {
360
372
  var html = '<div class="logsummary">running...</div>' +
361
373
  '<table class="logtable">' +
362
374
  '<thead><tr><th>Status</th><th>Test</th><th>Message</th></tr></thead>' +
@@ -365,7 +377,7 @@ DrNicTest.Unit.Logger.prototype._createLogTable = function() {
365
377
  this.element.innerHTML = html;
366
378
  };
367
379
 
368
- DrNicTest.Unit.Logger.prototype.appendActionButtons = function(actions) {
380
+ JsUnitTest.Unit.Logger.prototype.appendActionButtons = function(actions) {
369
381
  // actions = $H(actions);
370
382
  // if (!actions.any()) return;
371
383
  // var div = new Element("div", {className: 'action_buttons'});
@@ -377,22 +389,22 @@ DrNicTest.Unit.Logger.prototype.appendActionButtons = function(actions) {
377
389
  // this.getMessageCell().insert(div);
378
390
  };
379
391
 
380
- DrNicTest.Unit.Logger.prototype._toHTML = function(txt) {
381
- return DrNicTest.escapeHTML(txt).replace(/\n/g,"<br/>");
392
+ JsUnitTest.Unit.Logger.prototype._toHTML = function(txt) {
393
+ return JsUnitTest.escapeHTML(txt).replace(/\n/g,"<br/>");
382
394
  };
383
- DrNicTest.Unit.MessageTemplate = function(string) {
395
+ JsUnitTest.Unit.MessageTemplate = function(string) {
384
396
  var parts = [];
385
- var str = DrNicTest.scan((string || ''), /(?=[^\\])\?|(?:\\\?|[^\?])+/, function(part) {
397
+ var str = JsUnitTest.scan((string || ''), /(?=[^\\])\?|(?:\\\?|[^\?])+/, function(part) {
386
398
  parts.push(part[0]);
387
399
  });
388
400
  this.parts = parts;
389
401
  };
390
402
 
391
- DrNicTest.Unit.MessageTemplate.prototype.evaluate = function(params) {
403
+ JsUnitTest.Unit.MessageTemplate.prototype.evaluate = function(params) {
392
404
  var results = [];
393
405
  for (var i=0; i < this.parts.length; i++) {
394
406
  var part = this.parts[i];
395
- var result = (part == '?') ? DrNicTest.inspect(params.shift()) : part.replace(/\\\?/, '?');
407
+ var result = (part == '?') ? JsUnitTest.inspect(params.shift()) : part.replace(/\\\?/, '?');
396
408
  results.push(result);
397
409
  };
398
410
  return results.join('');
@@ -402,7 +414,7 @@ DrNicTest.Unit.MessageTemplate.prototype.evaluate = function(params) {
402
414
  // All of which are outline in the comments, below
403
415
  // From John Resig's book Pro JavaScript Techniques
404
416
  // published by Apress, 2006-8
405
- DrNicTest.ajax = function( options ) {
417
+ JsUnitTest.ajax = function( options ) {
406
418
 
407
419
  // Load the options object with defaults, if no
408
420
  // values were provided by the user
@@ -518,11 +530,11 @@ DrNicTest.ajax = function( options ) {
518
530
  }
519
531
 
520
532
  }
521
- DrNicTest.Unit.Assertions = {
533
+ JsUnitTest.Unit.Assertions = {
522
534
  buildMessage: function(message, template) {
523
- var args = DrNicTest.arrayfromargs(arguments).slice(2);
535
+ var args = JsUnitTest.arrayfromargs(arguments).slice(2);
524
536
  return (message ? message + '\n' : '') +
525
- new DrNicTest.Unit.MessageTemplate(template).evaluate(args);
537
+ new JsUnitTest.Unit.MessageTemplate(template).evaluate(args);
526
538
  },
527
539
 
528
540
  flunk: function(message) {
@@ -552,8 +564,8 @@ DrNicTest.Unit.Assertions = {
552
564
 
553
565
  assertEnumEqual: function(expected, actual, message) {
554
566
  message = this.buildMessage(message || 'assertEnumEqual', 'expected <?>, actual: <?>', expected, actual);
555
- var expected_array = DrNicTest.flattenArray(expected);
556
- var actual_array = DrNicTest.flattenArray(actual);
567
+ var expected_array = JsUnitTest.flattenArray(expected);
568
+ var actual_array = JsUnitTest.flattenArray(actual);
557
569
  this.assertBlock(message, function() {
558
570
  if (expected_array.length == actual_array.length) {
559
571
  for (var i=0; i < expected_array.length; i++) {
@@ -567,8 +579,8 @@ DrNicTest.Unit.Assertions = {
567
579
 
568
580
  assertEnumNotEqual: function(expected, actual, message) {
569
581
  message = this.buildMessage(message || 'assertEnumNotEqual', '<?> was the same as <?>', expected, actual);
570
- var expected_array = DrNicTest.flattenArray(expected);
571
- var actual_array = DrNicTest.flattenArray(actual);
582
+ var expected_array = JsUnitTest.flattenArray(expected);
583
+ var actual_array = JsUnitTest.flattenArray(actual);
572
584
  this.assertBlock(message, function() {
573
585
  if (expected_array.length == actual_array.length) {
574
586
  for (var i=0; i < expected_array.length; i++) {
@@ -582,8 +594,8 @@ DrNicTest.Unit.Assertions = {
582
594
 
583
595
  assertHashEqual: function(expected, actual, message) {
584
596
  message = this.buildMessage(message || 'assertHashEqual', 'expected <?>, actual: <?>', expected, actual);
585
- var expected_array = DrNicTest.flattenArray(DrNicTest.hashToSortedArray(expected));
586
- var actual_array = DrNicTest.flattenArray(DrNicTest.hashToSortedArray(actual));
597
+ var expected_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(expected));
598
+ var actual_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(actual));
587
599
  var block = function() {
588
600
  if (expected_array.length == actual_array.length) {
589
601
  for (var i=0; i < expected_array.length; i++) {
@@ -598,8 +610,8 @@ DrNicTest.Unit.Assertions = {
598
610
 
599
611
  assertHashNotEqual: function(expected, actual, message) {
600
612
  message = this.buildMessage(message || 'assertHashNotEqual', '<?> was the same as <?>', expected, actual);
601
- var expected_array = DrNicTest.flattenArray(DrNicTest.hashToSortedArray(expected));
602
- var actual_array = DrNicTest.flattenArray(DrNicTest.hashToSortedArray(actual));
613
+ var expected_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(expected));
614
+ var actual_array = JsUnitTest.flattenArray(JsUnitTest.hashToSortedArray(actual));
603
615
  // from now we recursively zip & compare nested arrays
604
616
  var block = function() {
605
617
  if (expected_array.length == actual_array.length) {
@@ -665,7 +677,7 @@ DrNicTest.Unit.Assertions = {
665
677
 
666
678
  assertHidden: function(element, message) {
667
679
  message = this.buildMessage(message || 'assertHidden', '? isn\'t hidden.', element);
668
- this.assertBlock(message, function() { return element.style.display == 'none' });
680
+ this.assertBlock(message, function() { return !element.style.display || element.style.display == 'none' });
669
681
  },
670
682
 
671
683
  assertInstanceOf: function(expected, actual, message) {
@@ -708,10 +720,10 @@ DrNicTest.Unit.Assertions = {
708
720
  },
709
721
 
710
722
  _isVisible: function(element) {
711
- element = DrNicTest.$(element);
723
+ element = JsUnitTest.$(element);
712
724
  if(!element.parentNode) return true;
713
725
  this.assertNotNull(element);
714
- if(element.style && element.style.display == 'none')
726
+ if(element.style && (element.style.display == 'none'))
715
727
  return false;
716
728
 
717
729
  return arguments.callee.call(this, element.parentNode);
@@ -728,7 +740,7 @@ DrNicTest.Unit.Assertions = {
728
740
  },
729
741
 
730
742
  assertElementsMatch: function() {
731
- var pass = true, expressions = DrNicTest.arrayfromargs(arguments);
743
+ var pass = true, expressions = JsUnitTest.arrayfromargs(arguments);
732
744
  var elements = expressions.shift();
733
745
  if (elements.length != expressions.length) {
734
746
  message = this.buildMessage('assertElementsMatch', 'size mismatch: ? elements, ? expressions (?).', elements.length, expressions.length, expressions);
@@ -737,8 +749,8 @@ DrNicTest.Unit.Assertions = {
737
749
  }
738
750
  for (var i=0; i < expressions.length; i++) {
739
751
  var expression = expressions[i];
740
- var element = DrNicTest.$(elements[i]);
741
- if (DrNicTest.selectorMatch(expression, element)) {
752
+ var element = JsUnitTest.$(elements[i]);
753
+ if (JsUnitTest.selectorMatch(expression, element)) {
742
754
  pass = true;
743
755
  break;
744
756
  }
@@ -753,28 +765,28 @@ DrNicTest.Unit.Assertions = {
753
765
  this.assertElementsMatch([element], expression);
754
766
  }
755
767
  };
756
- DrNicTest.Unit.Runner = function(testcases) {
768
+ JsUnitTest.Unit.Runner = function(testcases) {
757
769
  var argumentOptions = arguments[1] || {};
758
770
  var options = this.options = {};
759
771
  options.testLog = ('testLog' in argumentOptions) ? argumentOptions.testLog : 'testlog';
760
772
  options.resultsURL = this.queryParams.resultsURL;
761
- options.testLog = DrNicTest.$(options.testLog);
773
+ options.testLog = JsUnitTest.$(options.testLog);
762
774
 
763
775
  this.tests = this.getTests(testcases);
764
776
  this.currentTest = 0;
765
- this.logger = new DrNicTest.Unit.Logger(options.testLog);
777
+ this.logger = new JsUnitTest.Unit.Logger(options.testLog);
766
778
 
767
779
  var self = this;
768
- DrNicTest.Event.addEvent(window, "load", function() {
780
+ JsUnitTest.Event.addEvent(window, "load", function() {
769
781
  setTimeout(function() {
770
782
  self.runTests();
771
783
  }, 0.1);
772
784
  });
773
785
  };
774
786
 
775
- DrNicTest.Unit.Runner.prototype.queryParams = DrNicTest.toQueryParams();
787
+ JsUnitTest.Unit.Runner.prototype.queryParams = JsUnitTest.toQueryParams();
776
788
 
777
- DrNicTest.Unit.Runner.prototype.portNumber = function() {
789
+ JsUnitTest.Unit.Runner.prototype.portNumber = function() {
778
790
  if (window.location.search.length > 0) {
779
791
  var matches = window.location.search.match(/\:(\d{3,5})\//);
780
792
  if (matches) {
@@ -784,7 +796,7 @@ DrNicTest.Unit.Runner.prototype.portNumber = function() {
784
796
  return null;
785
797
  };
786
798
 
787
- DrNicTest.Unit.Runner.prototype.getTests = function(testcases) {
799
+ JsUnitTest.Unit.Runner.prototype.getTests = function(testcases) {
788
800
  var tests = [], options = this.options;
789
801
  if (this.queryParams.tests) tests = this.queryParams.tests.split(',');
790
802
  else if (options.tests) tests = options.tests;
@@ -799,13 +811,13 @@ DrNicTest.Unit.Runner.prototype.getTests = function(testcases) {
799
811
  var test = tests[i];
800
812
  if (testcases[test])
801
813
  results.push(
802
- new DrNicTest.Unit.Testcase(test, testcases[test], testcases.setup, testcases.teardown)
814
+ new JsUnitTest.Unit.Testcase(test, testcases[test], testcases.setup, testcases.teardown)
803
815
  );
804
816
  };
805
817
  return results;
806
818
  };
807
819
 
808
- DrNicTest.Unit.Runner.prototype.getResult = function() {
820
+ JsUnitTest.Unit.Runner.prototype.getResult = function() {
809
821
  var results = {
810
822
  tests: this.tests.length,
811
823
  assertions: 0,
@@ -822,7 +834,7 @@ DrNicTest.Unit.Runner.prototype.getResult = function() {
822
834
  return results;
823
835
  };
824
836
 
825
- DrNicTest.Unit.Runner.prototype.postResults = function() {
837
+ JsUnitTest.Unit.Runner.prototype.postResults = function() {
826
838
  if (this.options.resultsURL) {
827
839
  // new Ajax.Request(this.options.resultsURL,
828
840
  // { method: 'get', parameters: this.getResult(), asynchronous: false });
@@ -831,14 +843,14 @@ DrNicTest.Unit.Runner.prototype.postResults = function() {
831
843
  url += "assertions="+ results.assertions + "&";
832
844
  url += "failures=" + results.failures + "&";
833
845
  url += "errors=" + results.errors;
834
- DrNicTest.ajax({
846
+ JsUnitTest.ajax({
835
847
  url: url,
836
848
  type: 'GET'
837
849
  })
838
850
  }
839
851
  };
840
852
 
841
- DrNicTest.Unit.Runner.prototype.runTests = function() {
853
+ JsUnitTest.Unit.Runner.prototype.runTests = function() {
842
854
  var test = this.tests[this.currentTest], actions;
843
855
 
844
856
  if (!test) return this.finish();
@@ -861,15 +873,15 @@ DrNicTest.Unit.Runner.prototype.runTests = function() {
861
873
  this.runTests();
862
874
  };
863
875
 
864
- DrNicTest.Unit.Runner.prototype.finish = function() {
876
+ JsUnitTest.Unit.Runner.prototype.finish = function() {
865
877
  this.postResults();
866
878
  this.logger.summary(this.summary());
867
879
  };
868
880
 
869
- DrNicTest.Unit.Runner.prototype.summary = function() {
870
- return new DrNicTest.Template('#{tests} tests, #{assertions} assertions, #{failures} failures, #{errors} errors').evaluate(this.getResult());
881
+ JsUnitTest.Unit.Runner.prototype.summary = function() {
882
+ return new JsUnitTest.Template('#{tests} tests, #{assertions} assertions, #{failures} failures, #{errors} errors').evaluate(this.getResult());
871
883
  };
872
- DrNicTest.Unit.Testcase = function(name, test, setup, teardown) {
884
+ JsUnitTest.Unit.Testcase = function(name, test, setup, teardown) {
873
885
  this.name = name;
874
886
  this.test = test || function() {};
875
887
  this.setup = setup || function() {};
@@ -877,27 +889,27 @@ DrNicTest.Unit.Testcase = function(name, test, setup, teardown) {
877
889
  this.messages = [];
878
890
  this.actions = {};
879
891
  };
880
- // import DrNicTest.Unit.Assertions
892
+ // import JsUnitTest.Unit.Assertions
881
893
 
882
- for (method in DrNicTest.Unit.Assertions) {
883
- DrNicTest.Unit.Testcase.prototype[method] = DrNicTest.Unit.Assertions[method];
894
+ for (method in JsUnitTest.Unit.Assertions) {
895
+ JsUnitTest.Unit.Testcase.prototype[method] = JsUnitTest.Unit.Assertions[method];
884
896
  }
885
897
 
886
- DrNicTest.Unit.Testcase.prototype.isWaiting = false;
887
- DrNicTest.Unit.Testcase.prototype.timeToWait = 1000;
888
- DrNicTest.Unit.Testcase.prototype.assertions = 0;
889
- DrNicTest.Unit.Testcase.prototype.failures = 0;
890
- DrNicTest.Unit.Testcase.prototype.errors = 0;
891
- // DrNicTest.Unit.Testcase.prototype.isRunningFromRake = window.location.port == 4711;
892
- DrNicTest.Unit.Testcase.prototype.isRunningFromRake = window.location.port;
898
+ JsUnitTest.Unit.Testcase.prototype.isWaiting = false;
899
+ JsUnitTest.Unit.Testcase.prototype.timeToWait = 1000;
900
+ JsUnitTest.Unit.Testcase.prototype.assertions = 0;
901
+ JsUnitTest.Unit.Testcase.prototype.failures = 0;
902
+ JsUnitTest.Unit.Testcase.prototype.errors = 0;
903
+ // JsUnitTest.Unit.Testcase.prototype.isRunningFromRake = window.location.port == 4711;
904
+ JsUnitTest.Unit.Testcase.prototype.isRunningFromRake = window.location.port;
893
905
 
894
- DrNicTest.Unit.Testcase.prototype.wait = function(time, nextPart) {
906
+ JsUnitTest.Unit.Testcase.prototype.wait = function(time, nextPart) {
895
907
  this.isWaiting = true;
896
908
  this.test = nextPart;
897
909
  this.timeToWait = time;
898
910
  };
899
911
 
900
- DrNicTest.Unit.Testcase.prototype.run = function(rethrow) {
912
+ JsUnitTest.Unit.Testcase.prototype.run = function(rethrow) {
901
913
  try {
902
914
  try {
903
915
  if (!this.isWaiting) this.setup();
@@ -915,17 +927,17 @@ DrNicTest.Unit.Testcase.prototype.run = function(rethrow) {
915
927
  }
916
928
  };
917
929
 
918
- DrNicTest.Unit.Testcase.prototype.summary = function() {
930
+ JsUnitTest.Unit.Testcase.prototype.summary = function() {
919
931
  var msg = '#{assertions} assertions, #{failures} failures, #{errors} errors\n';
920
- return new DrNicTest.Template(msg).evaluate(this) +
932
+ return new JsUnitTest.Template(msg).evaluate(this) +
921
933
  this.messages.join("\n");
922
934
  };
923
935
 
924
- DrNicTest.Unit.Testcase.prototype.pass = function() {
936
+ JsUnitTest.Unit.Testcase.prototype.pass = function() {
925
937
  this.assertions++;
926
938
  };
927
939
 
928
- DrNicTest.Unit.Testcase.prototype.fail = function(message) {
940
+ JsUnitTest.Unit.Testcase.prototype.fail = function(message) {
929
941
  this.failures++;
930
942
  var line = "";
931
943
  try {
@@ -936,23 +948,23 @@ DrNicTest.Unit.Testcase.prototype.fail = function(message) {
936
948
  this.messages.push("Failure: " + message + (line ? " Line #" + line : ""));
937
949
  };
938
950
 
939
- DrNicTest.Unit.Testcase.prototype.info = function(message) {
951
+ JsUnitTest.Unit.Testcase.prototype.info = function(message) {
940
952
  this.messages.push("Info: " + message);
941
953
  };
942
954
 
943
- DrNicTest.Unit.Testcase.prototype.error = function(error, test) {
955
+ JsUnitTest.Unit.Testcase.prototype.error = function(error, test) {
944
956
  this.errors++;
945
957
  this.actions['retry with throw'] = function() { test.run(true) };
946
- this.messages.push(error.name + ": "+ error.message + "(" + DrNicTest.inspect(error) + ")");
958
+ this.messages.push(error.name + ": "+ error.message + "(" + JsUnitTest.inspect(error) + ")");
947
959
  };
948
960
 
949
- DrNicTest.Unit.Testcase.prototype.status = function() {
961
+ JsUnitTest.Unit.Testcase.prototype.status = function() {
950
962
  if (this.failures > 0) return 'failed';
951
963
  if (this.errors > 0) return 'error';
952
964
  return 'passed';
953
965
  };
954
966
 
955
- DrNicTest.Unit.Testcase.prototype.benchmark = function(operation, iterations) {
967
+ JsUnitTest.Unit.Testcase.prototype.benchmark = function(operation, iterations) {
956
968
  var startAt = new Date();
957
969
  (iterations || 1).times(operation);
958
970
  var timeTaken = ((new Date())-startAt);
@@ -961,4 +973,4 @@ DrNicTest.Unit.Testcase.prototype.benchmark = function(operation, iterations) {
961
973
  return timeTaken;
962
974
  };
963
975
 
964
- Test = DrNicTest
976
+ Test = JsUnitTest
@@ -31,7 +31,7 @@
31
31
  <h1>JavaScript Project Generator</h1>
32
32
  <div id="version" class="clickable" onclick='document.location = "http://rubyforge.org/projects/newjs"; return false'>
33
33
  <p>Get Version</p>
34
- <a href="http://rubyforge.org/projects/newjs" class="numbers">1.3.6</a>
34
+ <a href="http://rubyforge.org/projects/newjs" class="numbers">1.3.7</a>
35
35
  </div>
36
36
  <h1>&#x2192; &#8216;newjs&#8217;</h1>
37
37
 
@@ -39,7 +39,7 @@ blockquote {
39
39
  }
40
40
 
41
41
  #main {
42
- width: 50em;
42
+ width: 45em;
43
43
  padding: 0;
44
44
  margin: 0 auto;
45
45
  }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newjs
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.6
4
+ version: 1.3.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dr Nic Williams
@@ -9,7 +9,7 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2008-02-21 00:00:00 +10:00
12
+ date: 2008-03-04 00:00:00 +10:00
13
13
  default_executable:
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency