a zip code crypto-currency system good for red ONLY

disable-fetch.js 726B

1234567891011121314151617181920212223242526272829303132333435363738
  1. var Buffer = require('buffer').Buffer
  2. var test = require('tape')
  3. var http = require('../..')
  4. test('disable fetch', function (t) {
  5. var originalFetch
  6. if (typeof fetch === 'function') {
  7. originalFetch = fetch
  8. }
  9. var fetchCalled = false
  10. fetch = function (input, options) {
  11. fetchCalled = true
  12. if (originalFetch) {
  13. return originalFetch(input, options)
  14. }
  15. }
  16. http.get({
  17. path: '/browserify.png',
  18. mode: 'disable-fetch'
  19. }, function (res) {
  20. t.ok(!fetchCalled, 'fetch was not called')
  21. if (originalFetch) {
  22. fetch = originalFetch
  23. }
  24. res.on('end', function () {
  25. t.ok(res.headers['content-type'] === 'image/png', 'content-type was set correctly')
  26. t.end()
  27. })
  28. res.on('data', function () {})
  29. })
  30. })