a zip code crypto-currency system good for red ONLY

text.js 1.4KB

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. var Buffer = require('buffer').Buffer
  2. var fs = require('fs')
  3. var test = require('tape')
  4. var UAParser = require('ua-parser-js')
  5. var url = require('url')
  6. var http = require('../..')
  7. var browser = (new UAParser()).setUA(navigator.userAgent).getBrowser()
  8. var browserName = browser.name
  9. var browserVersion = browser.major
  10. // Response urls don't work on many browsers
  11. var skipResponseUrl = ((browserName === 'IE') ||
  12. (browserName === 'Edge') ||
  13. (browserName === 'Chrome' && browserVersion <= 36) ||
  14. (browserName === 'Firefox' && browserVersion <= 31) ||
  15. ((browserName === 'Safari' || browserName === 'Mobile Safari') && browserVersion <= 8) ||
  16. (browserName === 'WebKit') || // Old mobile safari
  17. (browserName === 'Android Browser' && browserVersion <= 4))
  18. var reference = fs.readFileSync(__dirname + '/../server/static/basic.txt')
  19. test('basic functionality', function (t) {
  20. http.get('/basic.txt', function (res) {
  21. if (!skipResponseUrl) {
  22. var testUrl = url.resolve(global.location.href, '/basic.txt')
  23. // Redirects aren't tested, but presumably only browser bugs
  24. // would cause this to fail only after redirects.
  25. t.equals(res.url, testUrl, 'response url correct')
  26. }
  27. var buffers = []
  28. res.on('end', function () {
  29. t.ok(reference.equals(Buffer.concat(buffers)), 'contents match')
  30. t.end()
  31. })
  32. res.on('data', function (data) {
  33. buffers.push(data)
  34. })
  35. })
  36. })