@warp-drive/holodeck 0.1.0-alpha.50 → 0.1.0-alpha.52

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.
@@ -63,3 +63,23 @@ export declare function PATCH(owner: object, url: string, response: ResponseGene
63
63
  export declare function DELETE(owner: object, url: string, response: ResponseGenerator, options?: Partial<Omit<Scaffold, "response" | "url" | "method">> & {
64
64
  RECORD?: boolean;
65
65
  }): Promise<void>;
66
+ /**
67
+ * Sets up Mocking for a HEAD request on the mock server
68
+ * for the supplied url.
69
+ *
70
+ * The response body is generated by the supplied response function.
71
+ *
72
+ * Available options:
73
+ * - status: the status code to return (default: 200)
74
+ * - headers: the headers to return (default: {})
75
+ * - body: the body to match against for the request (default: null)
76
+ * - RECORD: whether to record the request (default: false)
77
+ *
78
+ * @param url the url to mock, relative to the mock server host (e.g. `users/1`)
79
+ * @param response a function which generates the response to return
80
+ * @param options status, headers for the response, body to match against for the request, and whether to record the request
81
+ * @return
82
+ */
83
+ export declare function HEAD(owner: object, url: string, response: ResponseGenerator, options?: Partial<Omit<Scaffold, "response" | "url" | "method">> & {
84
+ RECORD?: boolean;
85
+ }): Promise<void>;
package/dist/mock.js CHANGED
@@ -117,4 +117,37 @@ function DELETE(owner, url, response, options) {
117
117
  }, getIsRecording() || (options?.RECORD ?? false));
118
118
  }
119
119
 
120
- export { DELETE, GET, PATCH, POST, PUT };
120
+ /**
121
+ * Sets up Mocking for a HEAD request on the mock server
122
+ * for the supplied url.
123
+ *
124
+ * The response body is generated by the supplied response function.
125
+ *
126
+ * Available options:
127
+ * - status: the status code to return (default: 200)
128
+ * - headers: the headers to return (default: {})
129
+ * - body: the body to match against for the request (default: null)
130
+ * - RECORD: whether to record the request (default: false)
131
+ *
132
+ * @param url the url to mock, relative to the mock server host (e.g. `users/1`)
133
+ * @param response a function which generates the response to return
134
+ * @param options status, headers for the response, body to match against for the request, and whether to record the request
135
+ * @return
136
+ */
137
+ function HEAD(owner, url, response,
138
+ // TODO: should we omit the `body` as well?
139
+ // It does _seem_ possible for HEAD requests to have a body, but it should be ignored.
140
+ // From MDN: Warning: If a response to a HEAD request has a body, the response body must be ignored.
141
+ options) {
142
+ return mock(owner, () => ({
143
+ status: options?.status ?? 200,
144
+ statusText: options?.statusText ?? 'OK',
145
+ headers: options?.headers ?? {},
146
+ body: options?.body ?? null,
147
+ method: 'HEAD',
148
+ url,
149
+ response: response()
150
+ }), getIsRecording() || (options?.RECORD ?? false));
151
+ }
152
+
153
+ export { DELETE, GET, HEAD, PATCH, POST, PUT };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@warp-drive/holodeck",
3
3
  "description": "⚡️ Simple, Fast HTTP Mocking for Tests",
4
- "version": "0.1.0-alpha.50",
4
+ "version": "0.1.0-alpha.52",
5
5
  "license": "MIT",
6
6
  "author": "Chris Thoburn <runspired@users.noreply.github.com>",
7
7
  "repository": {
@@ -39,9 +39,9 @@
39
39
  "ensure-cert": "./server/ensure-cert.js"
40
40
  },
41
41
  "peerDependencies": {
42
- "@warp-drive/utilities": "5.9.0-alpha.7",
43
- "@warp-drive/legacy": "5.9.0-alpha.7",
44
- "@warp-drive/core": "5.9.0-alpha.7"
42
+ "@warp-drive/utilities": "5.9.0-alpha.9",
43
+ "@warp-drive/legacy": "5.9.0-alpha.9",
44
+ "@warp-drive/core": "5.9.0-alpha.9"
45
45
  },
46
46
  "peerDependenciesMeta": {
47
47
  "@warp-drive/utilities": {
@@ -57,10 +57,10 @@
57
57
  "@babel/preset-env": "^7.28.3",
58
58
  "@babel/preset-typescript": "^7.27.1",
59
59
  "@babel/runtime": "^7.28.3",
60
- "@warp-drive/utilities": "5.9.0-alpha.7",
61
- "@warp-drive/legacy": "5.9.0-alpha.7",
62
- "@warp-drive/core": "5.9.0-alpha.7",
63
- "@warp-drive/internal-config": "5.9.0-alpha.7",
60
+ "@warp-drive/utilities": "5.9.0-alpha.9",
61
+ "@warp-drive/legacy": "5.9.0-alpha.9",
62
+ "@warp-drive/core": "5.9.0-alpha.9",
63
+ "@warp-drive/internal-config": "5.9.0-alpha.9",
64
64
  "vite": "^7.3.1"
65
65
  },
66
66
  "exports": {