@schmock/core 1.13.0 → 2.0.1

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.
Files changed (40) hide show
  1. package/dist/builder.d.ts +2 -0
  2. package/dist/builder.d.ts.map +1 -1
  3. package/dist/builder.js +13 -0
  4. package/dist/constants.d.ts +8 -0
  5. package/dist/constants.d.ts.map +1 -1
  6. package/dist/constants.js +12 -0
  7. package/dist/helpers.d.ts +9 -0
  8. package/dist/helpers.d.ts.map +1 -0
  9. package/dist/helpers.js +37 -0
  10. package/dist/index.d.ts +4 -2
  11. package/dist/index.d.ts.map +1 -1
  12. package/dist/index.js +7 -1
  13. package/dist/interceptor.d.ts +5 -0
  14. package/dist/interceptor.d.ts.map +1 -0
  15. package/dist/interceptor.js +213 -0
  16. package/dist/plugin-pipeline.js +1 -1
  17. package/dist/types.d.ts +5 -0
  18. package/dist/types.d.ts.map +1 -1
  19. package/package.json +1 -1
  20. package/src/builder.ts +23 -0
  21. package/src/constants.test.ts +40 -0
  22. package/src/constants.ts +18 -0
  23. package/src/helpers.test.ts +147 -0
  24. package/src/helpers.ts +58 -0
  25. package/src/index.ts +21 -0
  26. package/src/interceptor.test.ts +291 -0
  27. package/src/interceptor.ts +272 -0
  28. package/src/parser.property.test.ts +101 -0
  29. package/src/plugin-pipeline.ts +1 -1
  30. package/src/response-parsing.test.ts +74 -0
  31. package/src/server.test.ts +49 -0
  32. package/src/steps/async-support.steps.ts +0 -35
  33. package/src/steps/basic-usage.steps.ts +0 -84
  34. package/src/steps/developer-experience.steps.ts +0 -269
  35. package/src/steps/error-handling.steps.ts +0 -66
  36. package/src/steps/http-methods.steps.ts +0 -66
  37. package/src/steps/interceptor.steps.ts +206 -0
  38. package/src/steps/request-history.steps.ts +0 -75
  39. package/src/steps/route-key-format.steps.ts +0 -19
  40. package/src/types.ts +5 -0
@@ -9,57 +9,6 @@ describeFeature(feature, ({ Scenario }) => {
9
9
  let mock: CallableMockInstance;
10
10
  let response: any;
11
11
 
12
- Scenario("No requests recorded initially", ({ Given, Then, And }) => {
13
- Given("I create a mock with a single GET route for history", () => {
14
- mock = schmock();
15
- mock("GET /users", [{ id: 1 }]);
16
- });
17
-
18
- Then("the mock should not have been called", () => {
19
- expect(mock.called()).toBe(false);
20
- });
21
-
22
- And("the call count should be 0", () => {
23
- expect(mock.callCount()).toBe(0);
24
- });
25
-
26
- And("the history should be empty", () => {
27
- expect(mock.history()).toEqual([]);
28
- });
29
- });
30
-
31
- Scenario("Record a single GET request", ({ Given, When, Then, And }) => {
32
- Given("I create a mock returning users at {string}", (_, route: string) => {
33
- mock = schmock();
34
- mock(route as Schmock.RouteKey, [{ id: 1, name: "John" }]);
35
- });
36
-
37
- When("I request {string}", async (_, request: string) => {
38
- const [method, path] = request.split(" ");
39
- response = await mock.handle(method as any, path);
40
- });
41
-
42
- Then("the mock should have been called", () => {
43
- expect(mock.called()).toBe(true);
44
- });
45
-
46
- And("the call count should be 1", () => {
47
- expect(mock.callCount()).toBe(1);
48
- });
49
-
50
- And("the history should have 1 entry", () => {
51
- expect(mock.history()).toHaveLength(1);
52
- });
53
-
54
- And("the last request method should be {string}", (_, method: string) => {
55
- expect(mock.lastRequest()?.method).toBe(method);
56
- });
57
-
58
- And("the last request path should be {string}", (_, path: string) => {
59
- expect(mock.lastRequest()?.path).toBe(path);
60
- });
61
- });
62
-
63
12
  Scenario("Record multiple requests", ({ Given, When, And, Then }) => {
64
13
  Given("I create a mock with GET and POST user routes", () => {
65
14
  mock = schmock();
@@ -287,30 +236,6 @@ describeFeature(feature, ({ Scenario }) => {
287
236
  );
288
237
  });
289
238
 
290
- Scenario("History works with namespaced mocks", ({ Given, When, Then, And }) => {
291
- Given("I create a namespaced mock under {string}", (_, namespace: string) => {
292
- mock = schmock({ namespace });
293
- mock("GET /users", [{ id: 1 }]);
294
- });
295
-
296
- When("I request {string}", async (_, request: string) => {
297
- const [method, path] = request.split(" ");
298
- response = await mock.handle(method as any, path);
299
- });
300
-
301
- Then("the mock should have been called", () => {
302
- expect(mock.called()).toBe(true);
303
- });
304
-
305
- And("the call count should be 1", () => {
306
- expect(mock.callCount()).toBe(1);
307
- });
308
-
309
- And("the last request path should be {string}", (_, path: string) => {
310
- expect(mock.lastRequest()?.path).toBe(path);
311
- });
312
- });
313
-
314
239
  Scenario("404 requests are not recorded in history", ({ Given, When, Then, And }) => {
315
240
  Given("I create a mock with only a users route", () => {
316
241
  mock = schmock();
@@ -78,25 +78,6 @@ describeFeature(feature, ({ Scenario, ScenarioOutline }) => {
78
78
  });
79
79
  });
80
80
 
81
- Scenario("Path with query string placeholder", ({ When, Then, And }) => {
82
- When("I parse route key {string}", (_, routeKey: string) => {
83
- result = parseRouteKey(routeKey);
84
- });
85
-
86
- Then("the method should be {string}", (_, expectedMethod: string) => {
87
- expect(result.method).toBe(expectedMethod);
88
- });
89
-
90
- And("the path should be {string}", (_, expectedPath: string) => {
91
- expect(result.path).toBe(expectedPath);
92
- });
93
-
94
- And("query parameters are handled separately at runtime", () => {
95
- // This is a documentation scenario - query params are not part of the route key
96
- expect(result.path).not.toContain("?");
97
- });
98
- });
99
-
100
81
  Scenario("Complex nested paths", ({ When, Then, And }) => {
101
82
  When("I parse route key {string}", (_, routeKey: string) => {
102
83
  result = parseRouteKey(routeKey);
package/src/types.ts CHANGED
@@ -29,3 +29,8 @@ export type SeedSource = Schmock.SeedSource;
29
29
  export type SeedConfig = Schmock.SeedConfig;
30
30
  export type CliOptions = Schmock.CliOptions;
31
31
  export type CliServer = Schmock.CliServer;
32
+ export type AdapterRequest = Schmock.AdapterRequest;
33
+ export type AdapterResponse = Schmock.AdapterResponse;
34
+ export type InterceptOptions = Schmock.InterceptOptions;
35
+ export type InterceptHandle = Schmock.InterceptHandle;
36
+ export type AdapterRequestOverride = Schmock.AdapterRequestOverride;