glynnbird commented on code in PR #314:
URL: https://github.com/apache/couchdb-nano/pull/314#discussion_r1827542528


##########
test/attachment.insert.test.js:
##########
@@ -82,31 +85,45 @@ test('should detect missing parameters (callback) - 
db.attachment.insert', () =>
 test('should be able to insert document attachment as stream - PUT 
/db/docname/attachment - db.attachment.insert', async () => {
   // mocks
   const response = { ok: true, id: 'docname', rev: '2-456' }
-  const scope = nock(COUCH_URL, { reqheaders: { 'content-type': 'image/jpg' } 
})
-    .put('/db/docname/logo.jpg?rev=1-150', image2)
-    .reply(200, response)
+  mockPool.intercept({
+    method: 'put',
+    path: '/db/docname/logo.jpg?rev=1-150',
+    body: (value) => {
+      return true
+    },
+    headers: {
+      'content-type': 'image/jpg'
+    }
+  }).reply(200, response, JSON_HEADERS)
 
   // test PUT /db/docname/attachment
   const rs = fs.createReadStream('./test/logo.jpg')
   const db = nano.db.use('db')
   const reply = await db.attachment.insert('docname', 'logo.jpg', rs, 
'image/jpg', { rev: '1-150' })
-  expect(reply).toStrictEqual(response)
-  expect(scope.isDone()).toBe(true)
+  assert.deepEqual(reply, response)
+  mockAgent.assertNoPendingInterceptors()
 })
 
 test('should be able to insert document attachment as stream with circular 
reference - PUT /db/docname/attachment - db.attachment.insert', async () => {
   // mocks
   const response = { ok: true, id: 'docname', rev: '2-456' }
-  const scope = nock(COUCH_URL, { reqheaders: { 'content-type': 'image/jpg' } 
})
-    .put('/db/docname/logo2.jpg?rev=1-150', image2)
-    .reply(200, response)
+  mockPool.intercept({
+    method: 'put',
+    path: '/db/docname/logo2.jpg?rev=1-150',
+    body: (value) => {

Review Comment:
   Are you saying that the test should actually verify that the expected body 
is present in the body? That's a not-unreasonable question :) 



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscr...@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to