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.

37 lines
726 B

4 years ago
  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. })