@pbvision/fastify-firestore-service 0.0.14 → 0.0.15
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/test/base-test.js +10 -10
package/package.json
CHANGED
package/test/base-test.js
CHANGED
|
@@ -108,13 +108,13 @@ function makeGotMockValue (body, status, callback) {
|
|
|
108
108
|
return mockValue
|
|
109
109
|
}
|
|
110
110
|
|
|
111
|
-
function
|
|
112
|
-
const
|
|
111
|
+
function mockNodeFetch () {
|
|
112
|
+
const nodeFetchMock = jest.fn().mockImplementation(({ body }) => {
|
|
113
113
|
expect(body).toEqual(zlib.brotliCompressSync('321'))
|
|
114
114
|
})
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
116
|
+
nodeFetchMock.mockResp = (body = '', statusCode = 200, callback) => {
|
|
117
|
+
nodeFetchMock.mockReturnValue(makeGotMockValue(body, statusCode, callback))
|
|
118
118
|
}
|
|
119
119
|
|
|
120
120
|
/**
|
|
@@ -124,8 +124,8 @@ function mockGot () {
|
|
|
124
124
|
* to check and see if they have a mock response to use; if no callback,
|
|
125
125
|
* provides a mock response then an error will be thrown
|
|
126
126
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
127
|
+
nodeFetchMock.mockRespWithCallback = (...callbacks) => {
|
|
128
|
+
nodeFetchMock.mockImplementation(request => {
|
|
129
129
|
const { url, ...options } = request
|
|
130
130
|
for (const callback of callbacks) {
|
|
131
131
|
const desiredHTTPResponse = callback(request)
|
|
@@ -148,11 +148,11 @@ function mockGot () {
|
|
|
148
148
|
}
|
|
149
149
|
|
|
150
150
|
// will respond to the next N requests with the specified N responses
|
|
151
|
-
|
|
151
|
+
nodeFetchMock.mockRespMulti = (...responses) => {
|
|
152
152
|
let idx = 0
|
|
153
153
|
function setupNextResponse () {
|
|
154
154
|
if (idx < responses.length) {
|
|
155
|
-
|
|
155
|
+
nodeFetchMock.mockResp(...responses[idx], setupNextResponse)
|
|
156
156
|
} else if (idx > responses.length) {
|
|
157
157
|
// exactly equal means we just got our last callback (okay)
|
|
158
158
|
throw new Error('more requests made than we had mock responses')
|
|
@@ -161,12 +161,12 @@ function mockGot () {
|
|
|
161
161
|
}
|
|
162
162
|
setupNextResponse()
|
|
163
163
|
}
|
|
164
|
-
return
|
|
164
|
+
return nodeFetchMock
|
|
165
165
|
}
|
|
166
166
|
|
|
167
167
|
export {
|
|
168
168
|
BaseAppTest,
|
|
169
169
|
BaseTest,
|
|
170
|
-
|
|
170
|
+
mockNodeFetch,
|
|
171
171
|
runTests
|
|
172
172
|
}
|