You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 

55 lines
1.1 KiB

  1. define([
  2. 'server/components/inventory'
  3. ], function(
  4. inventory
  5. ) {
  6. var components = ['inventory', 'reputation', 'dialogue'];
  7. return {
  8. stats: {
  9. succeeded: 0,
  10. failed: 0
  11. },
  12. init: function() {
  13. console.log('Testing Started');
  14. console.log();
  15. components.forEach(function(c) {
  16. this.runTest(c, require('server/components/' + c));
  17. }, this);
  18. console.log();
  19. console.log('Testing Completed');
  20. console.log('Succeeded: ' + this.stats.succeeded);
  21. console.log('Failed: ' + this.stats.failed);
  22. },
  23. runTest: function(testName, test) {
  24. for (var t in test) {
  25. try {
  26. if (test[t]()) {
  27. this.logError(testName, t);
  28. this.stats.failed++;
  29. }
  30. else
  31. this.stats.succeeded++;
  32. }
  33. catch (e) {
  34. this.stats.failed++;
  35. this.logError(testName, t, e);
  36. }
  37. }
  38. },
  39. logError: function(test, method, error) {
  40. var splitMethod = method.split('_');
  41. method = splitMethod[0];
  42. var variant = splitMethod[1];
  43. console.log('Failed: ' + test + '.' + method + ' (' + variant + ')');
  44. if (error)
  45. console.log(error);
  46. }
  47. };
  48. });