UI for Zipcoin Blue

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. (function () {
  2. var Testem = window.Testem
  3. var regex = /^((?:not )?ok) (\d+) (.+)$/
  4. Testem.useCustomAdapter(tapAdapter)
  5. function tapAdapter(socket){
  6. var results = {
  7. failed: 0
  8. , passed: 0
  9. , total: 0
  10. , tests: []
  11. }
  12. socket.emit('tests-start')
  13. Testem.handleConsoleMessage = function(msg){
  14. var m = msg.match(regex)
  15. if (m) {
  16. var passed = m[1] === 'ok'
  17. var test = {
  18. passed: passed ? 1 : 0,
  19. failed: passed ? 0 : 1,
  20. total: 1,
  21. id: m[2],
  22. name: m[3],
  23. items: []
  24. }
  25. if (passed) {
  26. results.passed++
  27. } else {
  28. console.error("failure", m)
  29. results.failed++
  30. }
  31. results.total++
  32. // console.log("emitted test", test)
  33. socket.emit('test-result', test)
  34. results.tests.push(test)
  35. } else if (msg === '# ok' || msg.match(/^# tests \d+/)){
  36. // console.log("emitted all test")
  37. socket.emit('all-test-results', results)
  38. }
  39. // return false if you want to prevent the console message from
  40. // going to the console
  41. // return false
  42. }
  43. }
  44. }())