Browse Source

deps: update `temp-write` to v5

Antoine du Hamel 3 năm trước cách đây
mục cha
commit
d01422937e
2 tập tin đã thay đổi với 13 bổ sung23 xóa
  1. 1 1
      package.json
  2. 12 22
      test/endtoend/xhr-limit/test.js

+ 1 - 1
package.json

@@ -126,8 +126,8 @@
     "size-limit": "4.5.6",
     "stringify-object": "3.3.0",
     "symbol-es6": "^0.1.2",
-    "temp-write": "3.4.0",
     "tar": "^6.1.0",
+    "temp-write": "^5.0.0",
     "terser": "^5.7.0",
     "tinyify": "3.0.0",
     "tsd": "^0.11.0",

+ 12 - 22
test/endtoend/xhr-limit/test.js

@@ -1,9 +1,19 @@
 /* global browser, expect, capabilities  */
 const http = require('http')
-const tempWrite = require('temp-write')
 const { Writable } = require('stream')
 const { supportsChooseFile } = require('../utils')
 
+const tempWrite = import('temp-write')
+async function make1kBFile () {
+  const size = 1024
+  const content = Buffer.allocUnsafe(size)
+  for (let i = 0; i < size; i++) {
+    content[i] = Math.floor(Math.random() * 255)
+  }
+
+  return { path: await (await tempWrite).default(content), content }
+}
+
 const devNull = () => Writable({
   write (chunk, enc, cb) {
     cb()
@@ -38,18 +48,7 @@ describe.skip('XHRUpload with `limit`', () => {
   })
 
   it('should start counting progress for all files', async () => {
-    const files = [
-      makeFile(1000),
-      makeFile(1000),
-      makeFile(1000),
-      makeFile(1000),
-      makeFile(1000),
-      makeFile(1000),
-      makeFile(1000),
-      makeFile(1000),
-      makeFile(1000),
-      makeFile(1000),
-    ]
+    const files = await Promise.all(Array.from({ length: 10 }, make1kBFile))
 
     const endpoint = `http://localhost:${server.address().port}`
     await browser.execute((endpoint) => {
@@ -87,12 +86,3 @@ describe.skip('XHRUpload with `limit`', () => {
     expect(status.complete).to.be.equal(2)
   })
 })
-
-function makeFile (size) {
-  const content = Buffer.allocUnsafe(size)
-  for (let i = 0; i < size; i++) {
-    content[i] = Math.floor(Math.random() * 255)
-  }
-
-  return { path: tempWrite.sync(content), content }
-}