Show:
  1. /**
  2. * An object object containing coverage result formatting methods.
  3. * @namespace Test
  4. * @module test
  5. * @class CoverageFormat
  6. * @static
  7. */
  8. YUITest.CoverageFormat = {
  9. /**
  10. * Returns the coverage report in JSON format. This is the straight
  11. * JSON representation of the native coverage report.
  12. * @param {Object} coverage The coverage report object.
  13. * @return {String} A JSON-formatted string of coverage data.
  14. * @method JSON
  15. * @namespace Test.CoverageFormat
  16. */
  17. JSON: function(coverage){
  18. return YUITest.Util.JSON.stringify(coverage);
  19. },
  20. /**
  21. * Returns the coverage report in a JSON format compatible with
  22. * Xdebug. See <a href="http://www.xdebug.com/docs/code_coverage">Xdebug Documentation</a>
  23. * for more information. Note: function coverage is not available
  24. * in this format.
  25. * @param {Object} coverage The coverage report object.
  26. * @return {String} A JSON-formatted string of coverage data.
  27. * @method XdebugJSON
  28. * @namespace Test.CoverageFormat
  29. */
  30. XdebugJSON: function(coverage){
  31. var report = {};
  32. for (var prop in coverage){
  33. if (coverage.hasOwnProperty(prop)){
  34. report[prop] = coverage[prop].lines;
  35. }
  36. }
  37. return YUITest.Util.JSON.stringify(coverage);
  38. }
  39. };