From 9c5df481edbab1251db7e0acb4f250dac5131dfe Mon Sep 17 00:00:00 2001
From: Samuel Bodin <samuel.bodin@algolia.com>
Date: Thu, 8 Aug 2019 18:48:33 +0200
Subject: [PATCH] fix(unpkg): remove json flag + add unit test

---
 src/__tests__/unpkg.test.js | 17 +++++++++++++++++
 src/unpkg.js                |  1 -
 2 files changed, 17 insertions(+), 1 deletion(-)
 create mode 100644 src/__tests__/unpkg.test.js

diff --git a/src/__tests__/unpkg.test.js b/src/__tests__/unpkg.test.js
new file mode 100644
index 000000000..24a2ec38d
--- /dev/null
+++ b/src/__tests__/unpkg.test.js
@@ -0,0 +1,17 @@
+import { fileExistsInUnpkg } from '../unpkg.js';
+
+describe('unpkg', () => {
+  it('should do a successful HEAD request', async () => {
+    const exists = await fileExistsInUnpkg('jest', '24.8.0', 'bin/jest.js');
+    expect(exists).toBe(true);
+  });
+
+  it('should do a failed HEAD request', async () => {
+    const exists = await fileExistsInUnpkg(
+      'jest',
+      '24.8.0',
+      'bin/notexists.js'
+    );
+    expect(exists).toBe(false);
+  });
+});
diff --git a/src/unpkg.js b/src/unpkg.js
index 4074130e1..4c4d1efbc 100644
--- a/src/unpkg.js
+++ b/src/unpkg.js
@@ -8,7 +8,6 @@ export async function fileExistsInUnpkg(pkg, version, path) {
   const uri = `${config.unpkgRoot}/${pkg}@${version}/${path}`;
   try {
     const response = await got(uri, {
-      json: true,
       method: 'HEAD',
     });
     return response.statusCode === 200;