@pact-foundation/pact 16.3.1 → 16.5.0
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/CHANGELOG.md +23 -0
- package/CONTRIBUTING.md +2 -2
- package/README.md +22 -12
- package/package.json +26 -47
- package/scripts/ci/build-and-test.sh +0 -3
- package/scripts/install-plugins.js +104 -0
- package/src/common/graphQL/configurationError.js +2 -22
- package/src/common/graphQL/configurationError.js.map +1 -1
- package/src/common/graphQL/graphQL.d.ts +2 -2
- package/src/common/graphQL/graphQL.js +11 -14
- package/src/common/graphQL/graphQL.js.map +1 -1
- package/src/common/graphQL/graphQLQueryError.js +2 -22
- package/src/common/graphQL/graphQLQueryError.js.map +1 -1
- package/src/common/logger.js +9 -9
- package/src/common/logger.js.map +1 -1
- package/src/common/matchingRules.d.ts +7 -1
- package/src/common/matchingRules.js +42 -22
- package/src/common/matchingRules.js.map +1 -1
- package/src/common/net.js +36 -42
- package/src/common/net.js.map +1 -1
- package/src/common/net.spec.js +39 -87
- package/src/common/net.spec.js.map +1 -1
- package/src/common/request.js +33 -82
- package/src/common/request.js.map +1 -1
- package/src/common/request.spec.js +29 -73
- package/src/common/request.spec.js.map +1 -1
- package/src/common/spec.js +3 -4
- package/src/common/spec.js.map +1 -1
- package/src/dsl/apolloGraphql.js +7 -25
- package/src/dsl/apolloGraphql.js.map +1 -1
- package/src/dsl/apolloGraphql.spec.js +21 -58
- package/src/dsl/apolloGraphql.spec.js.map +1 -1
- package/src/dsl/graphql.d.ts +2 -2
- package/src/dsl/graphql.js +29 -48
- package/src/dsl/graphql.js.map +1 -1
- package/src/dsl/graphql.spec.js +92 -117
- package/src/dsl/graphql.spec.js.map +1 -1
- package/src/dsl/interaction.d.ts +2 -2
- package/src/dsl/interaction.js +41 -48
- package/src/dsl/interaction.js.map +1 -1
- package/src/dsl/interaction.spec.js +109 -132
- package/src/dsl/interaction.spec.js.map +1 -1
- package/src/dsl/matchers.d.ts +2 -3
- package/src/dsl/matchers.js +19 -31
- package/src/dsl/matchers.js.map +1 -1
- package/src/dsl/matchers.spec.js +279 -289
- package/src/dsl/matchers.spec.js.map +1 -1
- package/src/dsl/message.d.ts +3 -3
- package/src/dsl/options.d.ts +3 -3
- package/src/dsl/verifier/proxy/hooks.d.ts +2 -2
- package/src/dsl/verifier/proxy/hooks.js +42 -112
- package/src/dsl/verifier/proxy/hooks.js.map +1 -1
- package/src/dsl/verifier/proxy/hooks.spec.js +86 -199
- package/src/dsl/verifier/proxy/hooks.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/messages.d.ts +2 -2
- package/src/dsl/verifier/proxy/messages.js +88 -106
- package/src/dsl/verifier/proxy/messages.js.map +1 -1
- package/src/dsl/verifier/proxy/parseBody.d.ts +1 -1
- package/src/dsl/verifier/proxy/parseBody.js +3 -3
- package/src/dsl/verifier/proxy/parseBody.js.map +1 -1
- package/src/dsl/verifier/proxy/parseBody.spec.js +35 -113
- package/src/dsl/verifier/proxy/parseBody.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/proxy.d.ts +2 -2
- package/src/dsl/verifier/proxy/proxy.js +22 -26
- package/src/dsl/verifier/proxy/proxy.js.map +1 -1
- package/src/dsl/verifier/proxy/proxy.spec.js +11 -53
- package/src/dsl/verifier/proxy/proxy.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/proxyRequest.d.ts +3 -3
- package/src/dsl/verifier/proxy/proxyRequest.js +7 -7
- package/src/dsl/verifier/proxy/proxyRequest.js.map +1 -1
- package/src/dsl/verifier/proxy/proxyRequest.spec.js +54 -104
- package/src/dsl/verifier/proxy/proxyRequest.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/stateHandler/setupStates.d.ts +3 -3
- package/src/dsl/verifier/proxy/stateHandler/setupStates.js +14 -18
- package/src/dsl/verifier/proxy/stateHandler/setupStates.js.map +1 -1
- package/src/dsl/verifier/proxy/stateHandler/setupStates.spec.js +76 -193
- package/src/dsl/verifier/proxy/stateHandler/setupStates.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.d.ts +2 -2
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.js +23 -72
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.js.map +1 -1
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.spec.js +37 -122
- package/src/dsl/verifier/proxy/stateHandler/stateHandler.spec.js.map +1 -1
- package/src/dsl/verifier/proxy/tracer.d.ts +1 -1
- package/src/dsl/verifier/proxy/tracer.js +42 -35
- package/src/dsl/verifier/proxy/tracer.js.map +1 -1
- package/src/dsl/verifier/proxy/types.d.ts +5 -5
- package/src/dsl/verifier/types.d.ts +3 -3
- package/src/dsl/verifier/verifier.d.ts +5 -1
- package/src/dsl/verifier/verifier.js +53 -60
- package/src/dsl/verifier/verifier.js.map +1 -1
- package/src/dsl/verifier/verifier.spec.js +84 -151
- package/src/dsl/verifier/verifier.spec.js.map +1 -1
- package/src/errors/configurationError.js +2 -22
- package/src/errors/configurationError.js.map +1 -1
- package/src/errors/graphQLQueryError.js +2 -22
- package/src/errors/graphQLQueryError.js.map +1 -1
- package/src/errors/matcherError.js +2 -22
- package/src/errors/matcherError.js.map +1 -1
- package/src/errors/verificationError.js +2 -22
- package/src/errors/verificationError.js.map +1 -1
- package/src/httpPact/ffi.d.ts +2 -2
- package/src/httpPact/ffi.js +28 -29
- package/src/httpPact/ffi.js.map +1 -1
- package/src/httpPact/ffi.spec.js +40 -83
- package/src/httpPact/ffi.spec.js.map +1 -1
- package/src/httpPact/index.d.ts +3 -3
- package/src/httpPact/index.js +92 -149
- package/src/httpPact/index.js.map +1 -1
- package/src/httpPact/index.spec.js +102 -195
- package/src/httpPact/index.spec.js.map +1 -1
- package/src/httpPact/tracing.js +20 -28
- package/src/httpPact/tracing.js.map +1 -1
- package/src/index.d.ts +25 -25
- package/src/index.js +29 -29
- package/src/index.js.map +1 -1
- package/src/messageConsumerPact.d.ts +5 -5
- package/src/messageConsumerPact.js +59 -53
- package/src/messageConsumerPact.js.map +1 -1
- package/src/messageConsumerPact.spec.js +55 -97
- package/src/messageConsumerPact.spec.js.map +1 -1
- package/src/messageProviderPact.d.ts +3 -3
- package/src/messageProviderPact.js +68 -85
- package/src/messageProviderPact.js.map +1 -1
- package/src/messageProviderPact.spec.js +96 -123
- package/src/messageProviderPact.spec.js.map +1 -1
- package/src/pact.integration.spec.js +242 -351
- package/src/pact.integration.spec.js.map +1 -1
- package/src/v3/display.d.ts +1 -1
- package/src/v3/display.js +44 -58
- package/src/v3/display.js.map +1 -1
- package/src/v3/ffi.js +20 -16
- package/src/v3/ffi.js.map +1 -1
- package/src/v3/ffi.spec.js +7 -42
- package/src/v3/ffi.spec.js.map +1 -1
- package/src/v3/graphql/graphQL.d.ts +4 -4
- package/src/v3/graphql/graphQL.js +50 -75
- package/src/v3/graphql/graphQL.js.map +1 -1
- package/src/v3/graphql/index.d.ts +1 -1
- package/src/v3/graphql/index.js +1 -1
- package/src/v3/graphql/index.js.map +1 -1
- package/src/v3/index.d.ts +4 -12
- package/src/v3/index.js +4 -12
- package/src/v3/index.js.map +1 -1
- package/src/v3/matchers.d.ts +15 -3
- package/src/v3/matchers.js +131 -148
- package/src/v3/matchers.js.map +1 -1
- package/src/v3/matchers.spec.js +281 -232
- package/src/v3/matchers.spec.js.map +1 -1
- package/src/v3/pact.d.ts +2 -2
- package/src/v3/pact.js +108 -151
- package/src/v3/pact.js.map +1 -1
- package/src/v3/pact.spec.js +94 -0
- package/src/v3/pact.spec.js.map +1 -0
- package/src/v3/types.d.ts +19 -3
- package/src/v3/types.js +22 -1
- package/src/v3/types.js.map +1 -1
- package/src/v4/graphql/graphQLInteractionWithRequest.d.ts +4 -4
- package/src/v4/graphql/graphQLInteractionWithRequest.js +21 -17
- package/src/v4/graphql/graphQLInteractionWithRequest.js.map +1 -1
- package/src/v4/graphql/graphQLRequestBuilder.d.ts +3 -3
- package/src/v4/graphql/graphQLRequestBuilder.js +18 -20
- package/src/v4/graphql/graphQLRequestBuilder.js.map +1 -1
- package/src/v4/graphql/index.d.ts +6 -6
- package/src/v4/graphql/index.js +21 -17
- package/src/v4/graphql/index.js.map +1 -1
- package/src/v4/graphql/types.d.ts +5 -5
- package/src/v4/http/index.d.ts +2 -2
- package/src/v4/http/index.js +53 -93
- package/src/v4/http/index.js.map +1 -1
- package/src/v4/http/index.spec.d.ts +1 -0
- package/src/v4/http/index.spec.js +73 -0
- package/src/v4/http/index.spec.js.map +1 -0
- package/src/v4/http/interactionWithCompleteRequest.d.ts +4 -7
- package/src/v4/http/interactionWithCompleteRequest.js +6 -10
- package/src/v4/http/interactionWithCompleteRequest.js.map +1 -1
- package/src/v4/http/interactionWithPlugin.d.ts +3 -3
- package/src/v4/http/interactionWithPlugin.js +14 -11
- package/src/v4/http/interactionWithPlugin.js.map +1 -1
- package/src/v4/http/interactionWithPluginRequest.d.ts +4 -3
- package/src/v4/http/interactionWithPluginRequest.js +17 -9
- package/src/v4/http/interactionWithPluginRequest.js.map +1 -1
- package/src/v4/http/interactionWithPluginResponse.d.ts +2 -2
- package/src/v4/http/interactionWithPluginResponse.js +10 -48
- package/src/v4/http/interactionWithPluginResponse.js.map +1 -1
- package/src/v4/http/interactionWithRequest.d.ts +4 -3
- package/src/v4/http/interactionWithRequest.js +17 -9
- package/src/v4/http/interactionWithRequest.js.map +1 -1
- package/src/v4/http/interactionWithRequest.spec.d.ts +1 -0
- package/src/v4/http/interactionWithRequest.spec.js +82 -0
- package/src/v4/http/interactionWithRequest.spec.js.map +1 -0
- package/src/v4/http/interactionWithResponse.d.ts +2 -2
- package/src/v4/http/interactionWithResponse.js +10 -48
- package/src/v4/http/interactionWithResponse.js.map +1 -1
- package/src/v4/http/requestBuilder.d.ts +4 -3
- package/src/v4/http/requestBuilder.js +36 -34
- package/src/v4/http/requestBuilder.js.map +1 -1
- package/src/v4/http/requestBuilder.spec.d.ts +1 -0
- package/src/v4/http/requestBuilder.spec.js +42 -0
- package/src/v4/http/requestBuilder.spec.js.map +1 -0
- package/src/v4/http/requestWithPluginBuilder.d.ts +3 -2
- package/src/v4/http/requestWithPluginBuilder.js +30 -46
- package/src/v4/http/requestWithPluginBuilder.js.map +1 -1
- package/src/v4/http/requestWithPluginBuilder.spec.d.ts +1 -0
- package/src/v4/http/requestWithPluginBuilder.spec.js +34 -0
- package/src/v4/http/requestWithPluginBuilder.spec.js.map +1 -0
- package/src/v4/http/responseBuilder.d.ts +4 -3
- package/src/v4/http/responseBuilder.js +28 -25
- package/src/v4/http/responseBuilder.js.map +1 -1
- package/src/v4/http/responseBuilder.spec.d.ts +1 -0
- package/src/v4/http/responseBuilder.spec.js +42 -0
- package/src/v4/http/responseBuilder.spec.js.map +1 -0
- package/src/v4/http/responseWithPluginBuilder.d.ts +1 -1
- package/src/v4/http/responseWithPluginBuilder.js +5 -25
- package/src/v4/http/responseWithPluginBuilder.js.map +1 -1
- package/src/v4/http/responseWithPluginBuilder.spec.d.ts +1 -0
- package/src/v4/http/responseWithPluginBuilder.spec.js +34 -0
- package/src/v4/http/responseWithPluginBuilder.spec.js.map +1 -0
- package/src/v4/http/types.d.ts +13 -4
- package/src/v4/http/unconfiguredInteraction.d.ts +6 -5
- package/src/v4/http/unconfiguredInteraction.js +31 -26
- package/src/v4/http/unconfiguredInteraction.js.map +1 -1
- package/src/v4/index.d.ts +6 -5
- package/src/v4/index.js +32 -35
- package/src/v4/index.js.map +1 -1
- package/src/v4/message/asynchronousMessage.d.ts +7 -6
- package/src/v4/message/asynchronousMessage.js +157 -190
- package/src/v4/message/asynchronousMessage.js.map +1 -1
- package/src/v4/message/index.d.ts +7 -6
- package/src/v4/message/index.js +188 -217
- package/src/v4/message/index.js.map +1 -1
- package/src/v4/message/types.d.ts +5 -3
- package/src/v4/types.d.ts +3 -3
- package/src/xml/index.d.ts +4 -0
- package/src/xml/index.js +21 -0
- package/src/xml/index.js.map +1 -0
- package/src/{v3/xml → xml}/xmlBuilder.d.ts +1 -3
- package/src/{v3/xml → xml}/xmlBuilder.js +7 -9
- package/src/xml/xmlBuilder.js.map +1 -0
- package/src/{v3/xml → xml}/xmlElement.d.ts +2 -2
- package/src/xml/xmlElement.js +73 -0
- package/src/xml/xmlElement.js.map +1 -0
- package/src/xml/xmlElement.spec.d.ts +1 -0
- package/src/xml/xmlElement.spec.js +107 -0
- package/src/xml/xmlElement.spec.js.map +1 -0
- package/src/xml/xmlNode.js +7 -0
- package/src/xml/xmlNode.js.map +1 -0
- package/src/{v3/xml → xml}/xmlText.d.ts +1 -1
- package/src/xml/xmlText.js +15 -0
- package/src/xml/xmlText.js.map +1 -0
- package/scripts/install-plugins +0 -106
- package/src/v3/xml/xmlBuilder.js.map +0 -1
- package/src/v3/xml/xmlElement.js +0 -90
- package/src/v3/xml/xmlElement.js.map +0 -1
- package/src/v3/xml/xmlElement.spec.js +0 -113
- package/src/v3/xml/xmlElement.spec.js.map +0 -1
- package/src/v3/xml/xmlNode.js +0 -10
- package/src/v3/xml/xmlNode.js.map +0 -1
- package/src/v3/xml/xmlText.js +0 -31
- package/src/v3/xml/xmlText.js.map +0 -1
- /package/src/v3/{xml/xmlElement.spec.d.ts → pact.spec.d.ts} +0 -0
- /package/src/{v3/xml → xml}/xmlNode.d.ts +0 -0
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
describe('V4 HTTP executeTest', () => {
|
|
6
|
+
afterEach(() => {
|
|
7
|
+
vitest_1.vi.restoreAllMocks();
|
|
8
|
+
});
|
|
9
|
+
const buildPactMock = (port) => {
|
|
10
|
+
return {
|
|
11
|
+
pactffiCreateMockServerForTransport: vitest_1.vi.fn().mockReturnValue(port),
|
|
12
|
+
mockServerMatchedSuccessfully: vitest_1.vi.fn().mockReturnValue(true),
|
|
13
|
+
mockServerMismatches: vitest_1.vi.fn().mockReturnValue([]),
|
|
14
|
+
cleanupMockServer: vitest_1.vi.fn().mockReturnValue(true),
|
|
15
|
+
writePactFile: vitest_1.vi.fn(),
|
|
16
|
+
cleanupPlugins: vitest_1.vi.fn(),
|
|
17
|
+
addPlugin: vitest_1.vi.fn(),
|
|
18
|
+
};
|
|
19
|
+
};
|
|
20
|
+
const baseOpts = { consumer: 'A', provider: 'B' };
|
|
21
|
+
describe('CORS option', () => {
|
|
22
|
+
it('passes corsPreflight: true by default when cors is not specified', async () => {
|
|
23
|
+
const pactMock = buildPactMock(1234);
|
|
24
|
+
await (0, _1.executeTest)(pactMock, baseOpts, async () => Promise.resolve(), () => { });
|
|
25
|
+
// biome-ignore lint/suspicious/noExplicitAny: accessing vitest mock internals after ConsumerPact cast
|
|
26
|
+
const stub = pactMock.pactffiCreateMockServerForTransport;
|
|
27
|
+
expect(stub).toHaveBeenCalledOnce();
|
|
28
|
+
const [, , config] = stub.mock.calls[0];
|
|
29
|
+
expect(JSON.parse(config)).toEqual({ corsPreflight: true });
|
|
30
|
+
});
|
|
31
|
+
it('passes corsPreflight: true when cors is explicitly true', async () => {
|
|
32
|
+
const pactMock = buildPactMock(1234);
|
|
33
|
+
await (0, _1.executeTest)(pactMock, { ...baseOpts, cors: true }, async () => Promise.resolve(), () => { });
|
|
34
|
+
// biome-ignore lint/suspicious/noExplicitAny: accessing vitest mock internals after ConsumerPact cast
|
|
35
|
+
const stub = pactMock.pactffiCreateMockServerForTransport;
|
|
36
|
+
const [, , config] = stub.mock.calls[0];
|
|
37
|
+
expect(JSON.parse(config)).toEqual({ corsPreflight: true });
|
|
38
|
+
});
|
|
39
|
+
it('passes corsPreflight: false when cors is explicitly false', async () => {
|
|
40
|
+
const pactMock = buildPactMock(1234);
|
|
41
|
+
await (0, _1.executeTest)(pactMock, { ...baseOpts, cors: false }, async () => Promise.resolve(), () => { });
|
|
42
|
+
// biome-ignore lint/suspicious/noExplicitAny: accessing vitest mock internals after ConsumerPact cast
|
|
43
|
+
const stub = pactMock.pactffiCreateMockServerForTransport;
|
|
44
|
+
const [, , config] = stub.mock.calls[0];
|
|
45
|
+
expect(JSON.parse(config)).toEqual({ corsPreflight: false });
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
describe('transport scheme', () => {
|
|
49
|
+
it('uses http scheme by default', async () => {
|
|
50
|
+
const pactMock = buildPactMock(1234);
|
|
51
|
+
await (0, _1.executeTest)(pactMock, baseOpts, async () => Promise.resolve(), () => { });
|
|
52
|
+
// biome-ignore lint/suspicious/noExplicitAny: accessing vitest mock internals after ConsumerPact cast
|
|
53
|
+
const stub = pactMock.pactffiCreateMockServerForTransport;
|
|
54
|
+
const [, transport] = stub.mock.calls[0];
|
|
55
|
+
expect(transport).toBe('http');
|
|
56
|
+
});
|
|
57
|
+
it('uses https scheme when tls is true', async () => {
|
|
58
|
+
const pactMock = buildPactMock(1234);
|
|
59
|
+
await (0, _1.executeTest)(pactMock, { ...baseOpts, tls: true }, async () => Promise.resolve(), () => { });
|
|
60
|
+
// biome-ignore lint/suspicious/noExplicitAny: accessing vitest mock internals after ConsumerPact cast
|
|
61
|
+
const stub = pactMock.pactffiCreateMockServerForTransport;
|
|
62
|
+
const [, transport] = stub.mock.calls[0];
|
|
63
|
+
expect(transport).toBe('https');
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
describe('when the mock server fails to start', () => {
|
|
67
|
+
it('throws an error when port is 0 or negative', async () => {
|
|
68
|
+
const pactMock = buildPactMock(-3);
|
|
69
|
+
await expect((0, _1.executeTest)(pactMock, baseOpts, async () => Promise.resolve(), () => { })).rejects.toThrow('Failed to start mock server');
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
});
|
|
73
|
+
//# sourceMappingURL=index.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.spec.js","sourceRoot":"","sources":["../../../../src/v4/http/index.spec.ts"],"names":[],"mappings":";;AACA,mCAA4B;AAC5B,wBAAgC;AAGhC,QAAQ,CAAC,qBAAqB,EAAE,GAAG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AClC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,qCAAqC,EAAE,GAAG,EAAE;QACnD,EAAE,CAAC,4CAA4C,EAAE,KAAK,IAAI,EAAE;YAC1D,MAAM,QAAQ,GAAG,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;YAEnC,MAAM,MAAM,CACV,IAAA,cAAW,EACT,QAAQ,EACR,QAAQ,EACR,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,EAAE,EAC7B,GAAG,EAAE,GAAE,CAAC,CACT,CACF,CAAC,OAAO,CAAC,OAAO,CAAC,6BAA6B,CAAC,CAAC;QACnD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,10 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { V4InteractionWithCompleteRequest,
|
|
1
|
+
import type { ConsumerInteraction, ConsumerPact } from '@pact-foundation/pact-core';
|
|
2
|
+
import type { PactV4Options, V4InteractionWithCompleteRequest, V4InteractionWithResponse, V4Response } from './types';
|
|
3
3
|
export declare class InteractionWithCompleteRequest implements V4InteractionWithCompleteRequest {
|
|
4
|
-
private pact;
|
|
5
|
-
private interaction;
|
|
6
|
-
private opts;
|
|
7
4
|
protected cleanupFn: () => void;
|
|
8
|
-
constructor(
|
|
9
|
-
withCompleteResponse(
|
|
5
|
+
constructor(_pact: ConsumerPact, _interaction: ConsumerInteraction, _opts: PactV4Options, cleanupFn: () => void);
|
|
6
|
+
withCompleteResponse(_response: V4Response): V4InteractionWithResponse;
|
|
10
7
|
}
|
|
@@ -1,19 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InteractionWithCompleteRequest = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
this.interaction = interaction;
|
|
8
|
-
this.opts = opts;
|
|
4
|
+
class InteractionWithCompleteRequest {
|
|
5
|
+
cleanupFn;
|
|
6
|
+
constructor(_pact, _interaction, _opts, cleanupFn) {
|
|
9
7
|
this.cleanupFn = cleanupFn;
|
|
10
8
|
throw Error('V4InteractionWithCompleteRequest is unimplemented');
|
|
11
9
|
}
|
|
12
|
-
|
|
13
|
-
InteractionWithCompleteRequest.prototype.withCompleteResponse = function (response) {
|
|
10
|
+
withCompleteResponse(_response) {
|
|
14
11
|
throw new Error('withCompleteResponse is not implemented');
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
}());
|
|
12
|
+
}
|
|
13
|
+
}
|
|
18
14
|
exports.InteractionWithCompleteRequest = InteractionWithCompleteRequest;
|
|
19
15
|
//# sourceMappingURL=interactionWithCompleteRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionWithCompleteRequest.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithCompleteRequest.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"interactionWithCompleteRequest.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithCompleteRequest.ts"],"names":[],"mappings":";;;AAWA,MAAa,8BAA8B;IAO7B;IAJZ,YACE,KAAmB,EACnB,YAAiC,EACjC,KAAoB,EACV,SAAqB;QAArB,cAAS,GAAT,SAAS,CAAY;QAE/B,MAAM,KAAK,CAAC,mDAAmD,CAAC,CAAC;IACnE,CAAC;IAED,oBAAoB,CAAC,SAAqB;QACxC,MAAM,IAAI,KAAK,CAAC,yCAAyC,CAAC,CAAC;IAC7D,CAAC;CACF;AAfD,wEAeC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { Path } from '../../v3';
|
|
3
|
-
import {
|
|
1
|
+
import type { ConsumerInteraction, ConsumerPact } from '@pact-foundation/pact-core';
|
|
2
|
+
import type { Path } from '../../v3';
|
|
3
|
+
import type { PactV4Options, PluginConfig, V4InteractionWithPlugin, V4InteractionWithPluginRequest, V4PluginRequestBuilderFunc } from './types';
|
|
4
4
|
export declare class InteractionWithPlugin implements V4InteractionWithPlugin {
|
|
5
5
|
private pact;
|
|
6
6
|
private interaction;
|
|
@@ -1,30 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InteractionWithPlugin = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
4
|
+
const matchers_1 = require("../../v3/matchers");
|
|
5
|
+
const interactionWithPluginRequest_1 = require("./interactionWithPluginRequest");
|
|
6
|
+
const requestWithPluginBuilder_1 = require("./requestWithPluginBuilder");
|
|
7
|
+
class InteractionWithPlugin {
|
|
8
|
+
pact;
|
|
9
|
+
interaction;
|
|
10
|
+
opts;
|
|
11
|
+
cleanupFn;
|
|
8
12
|
// tslint:disable:no-empty-function
|
|
9
|
-
|
|
13
|
+
constructor(pact, interaction, opts, cleanupFn) {
|
|
10
14
|
this.pact = pact;
|
|
11
15
|
this.interaction = interaction;
|
|
12
16
|
this.opts = opts;
|
|
13
17
|
this.cleanupFn = cleanupFn;
|
|
14
18
|
}
|
|
15
19
|
// Multiple plugins are allowed
|
|
16
|
-
|
|
20
|
+
usingPlugin(config) {
|
|
17
21
|
this.pact.addPlugin(config.plugin, config.version);
|
|
18
22
|
return this;
|
|
19
|
-
}
|
|
20
|
-
|
|
23
|
+
}
|
|
24
|
+
withRequest(method, path, builder) {
|
|
21
25
|
this.interaction.withRequest(method, (0, matchers_1.matcherValueOrString)(path));
|
|
22
26
|
if (typeof builder === 'function') {
|
|
23
27
|
builder(new requestWithPluginBuilder_1.RequestWithPluginBuilder(this.interaction));
|
|
24
28
|
}
|
|
25
29
|
return new interactionWithPluginRequest_1.InteractionWithPluginRequest(this.pact, this.interaction, this.opts, this.cleanupFn);
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
}());
|
|
30
|
+
}
|
|
31
|
+
}
|
|
29
32
|
exports.InteractionWithPlugin = InteractionWithPlugin;
|
|
30
33
|
//# sourceMappingURL=interactionWithPlugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionWithPlugin.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithPlugin.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"interactionWithPlugin.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithPlugin.ts"],"names":[],"mappings":";;;AAKA,gDAAyD;AACzD,iFAA8E;AAC9E,yEAAsE;AAStE,MAAa,qBAAqB;IAGtB;IACA;IACA;IACE;IALZ,mCAAmC;IACnC,YACU,IAAkB,EAClB,WAAgC,EAChC,IAAmB,EACjB,SAAqB;QAHvB,SAAI,GAAJ,IAAI,CAAc;QAClB,gBAAW,GAAX,WAAW,CAAqB;QAChC,SAAI,GAAJ,IAAI,CAAe;QACjB,cAAS,GAAT,SAAS,CAAY;IAC9B,CAAC;IAEJ,+BAA+B;IAC/B,WAAW,CAAC,MAAoB;QAC9B,IAAI,CAAC,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,OAAO,CAAC,CAAC;QAEnD,OAAO,IAAI,CAAC;IACd,CAAC;IAED,WAAW,CACT,MAAc,EACd,IAAU,EACV,OAAoC;QAEpC,IAAI,CAAC,WAAW,CAAC,WAAW,CAAC,MAAM,EAAE,IAAA,+BAAoB,EAAC,IAAI,CAAC,CAAC,CAAC;QAEjE,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,mDAAwB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAC1D,CAAC;QACD,OAAO,IAAI,2DAA4B,CACrC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,WAAW,EAChB,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,SAAS,CACf,CAAC;IACJ,CAAC;CACF;AAjCD,sDAiCC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { V4InteractionWithPluginRequest,
|
|
1
|
+
import type { ConsumerInteraction, ConsumerPact } from '@pact-foundation/pact-core';
|
|
2
|
+
import type { PactV4Options, V4InteractionWithPluginRequest, V4InteractionWithPluginResponse, V4PluginResponseBuilderFunc } from './types';
|
|
3
|
+
import type { StatusCodeMatcher } from '../../v3';
|
|
3
4
|
export declare class InteractionWithPluginRequest implements V4InteractionWithPluginRequest {
|
|
4
5
|
private pact;
|
|
5
6
|
private interaction;
|
|
6
7
|
private opts;
|
|
7
8
|
protected cleanupFn: () => void;
|
|
8
9
|
constructor(pact: ConsumerPact, interaction: ConsumerInteraction, opts: PactV4Options, cleanupFn: () => void);
|
|
9
|
-
willRespondWith(status: number
|
|
10
|
+
willRespondWith(status: number | StatusCodeMatcher<number>, builder?: V4PluginResponseBuilderFunc): V4InteractionWithPluginResponse;
|
|
10
11
|
}
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InteractionWithPluginRequest = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const interactionWithPluginResponse_1 = require("./interactionWithPluginResponse");
|
|
5
|
+
const responseWithPluginBuilder_1 = require("./responseWithPluginBuilder");
|
|
6
|
+
const matchers_1 = require("../../v3/matchers");
|
|
7
|
+
const matchingRules_1 = require("../../common/matchingRules");
|
|
8
|
+
class InteractionWithPluginRequest {
|
|
9
|
+
pact;
|
|
10
|
+
interaction;
|
|
11
|
+
opts;
|
|
12
|
+
cleanupFn;
|
|
7
13
|
// tslint:disable:no-empty-function
|
|
8
|
-
|
|
14
|
+
constructor(pact, interaction, opts, cleanupFn) {
|
|
9
15
|
this.pact = pact;
|
|
10
16
|
this.interaction = interaction;
|
|
11
17
|
this.opts = opts;
|
|
12
18
|
this.cleanupFn = cleanupFn;
|
|
13
19
|
}
|
|
14
|
-
|
|
15
|
-
this.interaction.withStatus(status);
|
|
20
|
+
willRespondWith(status, builder) {
|
|
21
|
+
this.interaction.withStatus((0, matchers_1.reify)(status));
|
|
22
|
+
if ((0, matchers_1.isStatusCodeMatcher)(status)) {
|
|
23
|
+
this.interaction.withResponseMatchingRules(JSON.stringify((0, matchingRules_1.convertStatusMatcherToFFI)(status)));
|
|
24
|
+
}
|
|
16
25
|
if (typeof builder === 'function') {
|
|
17
26
|
builder(new responseWithPluginBuilder_1.ResponseWithPluginBuilder(this.interaction));
|
|
18
27
|
}
|
|
19
28
|
return new interactionWithPluginResponse_1.InteractionWithPluginResponse(this.pact, this.opts, this.cleanupFn);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
}());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
23
31
|
exports.InteractionWithPluginRequest = InteractionWithPluginRequest;
|
|
24
32
|
//# sourceMappingURL=interactionWithPluginRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionWithPluginRequest.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithPluginRequest.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"interactionWithPluginRequest.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithPluginRequest.ts"],"names":[],"mappings":";;;AAIA,mFAAgF;AAChF,2EAAwE;AAQxE,gDAA+D;AAC/D,8DAAuE;AAEvE,MAAa,4BAA4B;IAK7B;IACA;IACA;IACE;IALZ,mCAAmC;IACnC,YACU,IAAkB,EAClB,WAAgC,EAChC,IAAmB,EACjB,SAAqB;QAHvB,SAAI,GAAJ,IAAI,CAAc;QAClB,gBAAW,GAAX,WAAW,CAAqB;QAChC,SAAI,GAAJ,IAAI,CAAe;QACjB,cAAS,GAAT,SAAS,CAAY;IAC9B,CAAC;IAEJ,eAAe,CACb,MAA0C,EAC1C,OAAqC;QAErC,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAA,gBAAK,EAAS,MAAM,CAAC,CAAC,CAAC;QAEnD,IAAI,IAAA,8BAAmB,EAAC,MAAM,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,yBAAyB,CACxC,IAAI,CAAC,SAAS,CAAC,IAAA,yCAAyB,EAAC,MAAM,CAAC,CAAC,CAClD,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,qDAAyB,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QAC3D,CAAC;QAED,OAAO,IAAI,6DAA6B,CACtC,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,IAAI,EACT,IAAI,CAAC,SAAS,CACf,CAAC;IACJ,CAAC;CACF;AAjCD,oEAiCC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConsumerPact } from '@pact-foundation/pact-core';
|
|
2
|
-
import {
|
|
1
|
+
import type { ConsumerPact } from '@pact-foundation/pact-core';
|
|
2
|
+
import type { PactV4Options, V4InteractionWithPluginResponse, V4MockServer } from './types';
|
|
3
3
|
export declare class InteractionWithPluginResponse implements V4InteractionWithPluginResponse {
|
|
4
4
|
private pact;
|
|
5
5
|
private opts;
|
|
@@ -1,58 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.InteractionWithPluginResponse = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
class InteractionWithPluginResponse {
|
|
6
|
+
pact;
|
|
7
|
+
opts;
|
|
8
|
+
cleanupFn;
|
|
42
9
|
// tslint:disable:no-empty-function
|
|
43
|
-
|
|
10
|
+
constructor(pact, opts, cleanupFn) {
|
|
44
11
|
this.pact = pact;
|
|
45
12
|
this.opts = opts;
|
|
46
13
|
this.cleanupFn = cleanupFn;
|
|
47
14
|
}
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
return InteractionWithPluginResponse;
|
|
56
|
-
}());
|
|
15
|
+
async executeTest(testFn) {
|
|
16
|
+
return (0, _1.executeTest)(this.pact, this.opts, testFn, this.cleanupFn);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
57
19
|
exports.InteractionWithPluginResponse = InteractionWithPluginResponse;
|
|
58
20
|
//# sourceMappingURL=interactionWithPluginResponse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionWithPluginResponse.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithPluginResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interactionWithPluginResponse.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithPluginResponse.ts"],"names":[],"mappings":";;;AACA,wBAAgC;AAOhC,MAAa,6BAA6B;IAK9B;IACA;IACE;IAJZ,mCAAmC;IACnC,YACU,IAAkB,EAClB,IAAmB,EACjB,SAAqB;QAFvB,SAAI,GAAJ,IAAI,CAAc;QAClB,SAAI,GAAJ,IAAI,CAAe;QACjB,cAAS,GAAT,SAAS,CAAY;IAC9B,CAAC;IAEJ,KAAK,CAAC,WAAW,CACf,MAAgD;QAEhD,OAAO,IAAA,cAAW,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC;CACF;AAfD,sEAeC"}
|
|
@@ -1,10 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { V4InteractionWithRequest,
|
|
1
|
+
import type { ConsumerInteraction, ConsumerPact } from '@pact-foundation/pact-core';
|
|
2
|
+
import type { PactV4Options, V4InteractionWithRequest, V4InteractionWithResponse, V4ResponseBuilderFunc } from './types';
|
|
3
|
+
import type { StatusCodeMatcher } from '../../v3';
|
|
3
4
|
export declare class InteractionWithRequest implements V4InteractionWithRequest {
|
|
4
5
|
private pact;
|
|
5
6
|
private interaction;
|
|
6
7
|
private opts;
|
|
7
8
|
protected cleanupFn: () => void;
|
|
8
9
|
constructor(pact: ConsumerPact, interaction: ConsumerInteraction, opts: PactV4Options, cleanupFn: () => void);
|
|
9
|
-
willRespondWith(status: number
|
|
10
|
+
willRespondWith(status: number | StatusCodeMatcher<number>, builder?: V4ResponseBuilderFunc): V4InteractionWithResponse;
|
|
10
11
|
}
|
|
@@ -1,24 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.InteractionWithRequest = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
4
|
+
const interactionWithResponse_1 = require("./interactionWithResponse");
|
|
5
|
+
const responseBuilder_1 = require("./responseBuilder");
|
|
6
|
+
const matchers_1 = require("../../v3/matchers");
|
|
7
|
+
const matchingRules_1 = require("../../common/matchingRules");
|
|
8
|
+
class InteractionWithRequest {
|
|
9
|
+
pact;
|
|
10
|
+
interaction;
|
|
11
|
+
opts;
|
|
12
|
+
cleanupFn;
|
|
7
13
|
// tslint:disable:no-empty-function
|
|
8
|
-
|
|
14
|
+
constructor(pact, interaction, opts, cleanupFn) {
|
|
9
15
|
this.pact = pact;
|
|
10
16
|
this.interaction = interaction;
|
|
11
17
|
this.opts = opts;
|
|
12
18
|
this.cleanupFn = cleanupFn;
|
|
13
19
|
}
|
|
14
|
-
|
|
15
|
-
this.interaction.withStatus(status);
|
|
20
|
+
willRespondWith(status, builder) {
|
|
21
|
+
this.interaction.withStatus((0, matchers_1.reify)(status));
|
|
22
|
+
if ((0, matchers_1.isStatusCodeMatcher)(status)) {
|
|
23
|
+
this.interaction.withResponseMatchingRules(JSON.stringify((0, matchingRules_1.convertStatusMatcherToFFI)(status)));
|
|
24
|
+
}
|
|
16
25
|
if (typeof builder === 'function') {
|
|
17
26
|
builder(new responseBuilder_1.ResponseBuilder(this.interaction));
|
|
18
27
|
}
|
|
19
28
|
return new interactionWithResponse_1.InteractionWithResponse(this.pact, this.opts, this.cleanupFn);
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
}());
|
|
29
|
+
}
|
|
30
|
+
}
|
|
23
31
|
exports.InteractionWithRequest = InteractionWithRequest;
|
|
24
32
|
//# sourceMappingURL=interactionWithRequest.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionWithRequest.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithRequest.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"interactionWithRequest.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithRequest.ts"],"names":[],"mappings":";;;AAIA,uEAAoE;AACpE,uDAAoD;AAQpD,gDAA+D;AAC/D,8DAAuE;AAEvE,MAAa,sBAAsB;IAGvB;IACA;IACA;IACE;IALZ,mCAAmC;IACnC,YACU,IAAkB,EAClB,WAAgC,EAChC,IAAmB,EACjB,SAAqB;QAHvB,SAAI,GAAJ,IAAI,CAAc;QAClB,gBAAW,GAAX,WAAW,CAAqB;QAChC,SAAI,GAAJ,IAAI,CAAe;QACjB,cAAS,GAAT,SAAS,CAAY;IAC9B,CAAC;IAEJ,eAAe,CACb,MAA0C,EAC1C,OAA+B;QAE/B,IAAI,CAAC,WAAW,CAAC,UAAU,CAAC,IAAA,gBAAK,EAAS,MAAM,CAAC,CAAC,CAAC;QAEnD,IAAI,IAAA,8BAAmB,EAAC,MAAM,CAAC,EAAE,CAAC;YAChC,IAAI,CAAC,WAAW,CAAC,yBAAyB,CACxC,IAAI,CAAC,SAAS,CAAC,IAAA,yCAAyB,EAAC,MAAM,CAAC,CAAC,CAClD,CAAC;QACJ,CAAC;QAED,IAAI,OAAO,OAAO,KAAK,UAAU,EAAE,CAAC;YAClC,OAAO,CAAC,IAAI,iCAAe,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;QACjD,CAAC;QAED,OAAO,IAAI,iDAAuB,CAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IAC3E,CAAC;CACF;AA3BD,wDA2BC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const vitest_1 = require("vitest");
|
|
4
|
+
const interactionWithRequest_1 = require("./interactionWithRequest");
|
|
5
|
+
const matchers_1 = require("../../v3/matchers");
|
|
6
|
+
describe('InteractionWithRequest', () => {
|
|
7
|
+
let withStatus;
|
|
8
|
+
let withResponseMatchingRules;
|
|
9
|
+
let interaction;
|
|
10
|
+
let pact;
|
|
11
|
+
let cleanupFn;
|
|
12
|
+
beforeEach(() => {
|
|
13
|
+
withStatus = vitest_1.vi.fn();
|
|
14
|
+
withResponseMatchingRules = vitest_1.vi.fn();
|
|
15
|
+
interaction = {
|
|
16
|
+
withStatus,
|
|
17
|
+
withResponseMatchingRules,
|
|
18
|
+
};
|
|
19
|
+
pact = {
|
|
20
|
+
pactffiCreateMockServerForTransport: vitest_1.vi.fn().mockReturnValue(1234),
|
|
21
|
+
mockServerMatchedSuccessfully: vitest_1.vi.fn().mockReturnValue(true),
|
|
22
|
+
mockServerMismatches: vitest_1.vi.fn().mockReturnValue([]),
|
|
23
|
+
cleanupMockServer: vitest_1.vi.fn().mockReturnValue(true),
|
|
24
|
+
writePactFile: vitest_1.vi.fn(),
|
|
25
|
+
cleanupPlugins: vitest_1.vi.fn(),
|
|
26
|
+
};
|
|
27
|
+
cleanupFn = vitest_1.vi.fn();
|
|
28
|
+
});
|
|
29
|
+
afterEach(() => {
|
|
30
|
+
vitest_1.vi.restoreAllMocks();
|
|
31
|
+
});
|
|
32
|
+
describe('#willRespondWith', () => {
|
|
33
|
+
it('calls withStatus with a plain number', () => {
|
|
34
|
+
const req = new interactionWithRequest_1.InteractionWithRequest(pact, interaction, { consumer: 'A', provider: 'B' }, cleanupFn);
|
|
35
|
+
req.willRespondWith(200);
|
|
36
|
+
expect(withStatus).toHaveBeenCalledOnce();
|
|
37
|
+
expect(withStatus).toHaveBeenCalledWith(200);
|
|
38
|
+
expect(withResponseMatchingRules).not.toHaveBeenCalled();
|
|
39
|
+
});
|
|
40
|
+
it('calls withStatus with the example value from a StatusCodeMatcher', () => {
|
|
41
|
+
const req = new interactionWithRequest_1.InteractionWithRequest(pact, interaction, { consumer: 'A', provider: 'B' }, cleanupFn);
|
|
42
|
+
const matcher = (0, matchers_1.matchStatus)(200, matchers_1.HTTPResponseStatusClass.Success);
|
|
43
|
+
req.willRespondWith(matcher);
|
|
44
|
+
expect(withStatus).toHaveBeenCalledOnce();
|
|
45
|
+
expect(withStatus).toHaveBeenCalledWith(200);
|
|
46
|
+
});
|
|
47
|
+
it('calls withResponseMatchingRules with status class matcher FFI format', () => {
|
|
48
|
+
const req = new interactionWithRequest_1.InteractionWithRequest(pact, interaction, { consumer: 'A', provider: 'B' }, cleanupFn);
|
|
49
|
+
const matcher = (0, matchers_1.matchStatus)(200, matchers_1.HTTPResponseStatusClass.Success);
|
|
50
|
+
req.willRespondWith(matcher);
|
|
51
|
+
expect(withResponseMatchingRules).toHaveBeenCalledOnce();
|
|
52
|
+
const rulesJson = JSON.parse(withResponseMatchingRules.mock.calls[0][0]);
|
|
53
|
+
expect(rulesJson).toEqual({
|
|
54
|
+
status: {
|
|
55
|
+
$: {
|
|
56
|
+
matchers: [{ match: 'statusCode', status: 'success' }],
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
it('calls withResponseMatchingRules with specific status code matcher format', () => {
|
|
62
|
+
const req = new interactionWithRequest_1.InteractionWithRequest(pact, interaction, { consumer: 'A', provider: 'B' }, cleanupFn);
|
|
63
|
+
const matcher = (0, matchers_1.matchStatus)(200, [200, 201]);
|
|
64
|
+
req.willRespondWith(matcher);
|
|
65
|
+
expect(withResponseMatchingRules).toHaveBeenCalledOnce();
|
|
66
|
+
const rulesJson = JSON.parse(withResponseMatchingRules.mock.calls[0][0]);
|
|
67
|
+
expect(rulesJson).toEqual({
|
|
68
|
+
status: {
|
|
69
|
+
$: {
|
|
70
|
+
matchers: [{ match: 'statusCode', status: [200, 201] }],
|
|
71
|
+
},
|
|
72
|
+
},
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
it('does not call withResponseMatchingRules for a plain number', () => {
|
|
76
|
+
const req = new interactionWithRequest_1.InteractionWithRequest(pact, interaction, { consumer: 'A', provider: 'B' }, cleanupFn);
|
|
77
|
+
req.willRespondWith(201);
|
|
78
|
+
expect(withResponseMatchingRules).not.toHaveBeenCalled();
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
});
|
|
82
|
+
//# sourceMappingURL=interactionWithRequest.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"interactionWithRequest.spec.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithRequest.spec.ts"],"names":[],"mappings":";;AAIA,mCAA4B;AAC5B,qEAAkE;AAClE,gDAAyE;AAEzE,QAAQ,CAAC,wBAAwB,EAAE,GAAG,EAAE;IACtC,IAAI,UAAoC,CAAC;IACzC,IAAI,yBA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CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { ConsumerPact } from '@pact-foundation/pact-core';
|
|
2
|
-
import {
|
|
1
|
+
import type { ConsumerPact } from '@pact-foundation/pact-core';
|
|
2
|
+
import type { PactV4Options, TestFunction, V4InteractionWithResponse } from './types';
|
|
3
3
|
export declare class InteractionWithResponse implements V4InteractionWithResponse {
|
|
4
4
|
private pact;
|
|
5
5
|
private opts;
|
|
@@ -1,58 +1,20 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
3
|
exports.InteractionWithResponse = void 0;
|
|
40
|
-
|
|
41
|
-
|
|
4
|
+
const _1 = require(".");
|
|
5
|
+
class InteractionWithResponse {
|
|
6
|
+
pact;
|
|
7
|
+
opts;
|
|
8
|
+
cleanupFn;
|
|
42
9
|
// tslint:disable:no-empty-function
|
|
43
|
-
|
|
10
|
+
constructor(pact, opts, cleanupFn) {
|
|
44
11
|
this.pact = pact;
|
|
45
12
|
this.opts = opts;
|
|
46
13
|
this.cleanupFn = cleanupFn;
|
|
47
14
|
}
|
|
48
|
-
|
|
49
|
-
return
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
});
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
return InteractionWithResponse;
|
|
56
|
-
}());
|
|
15
|
+
async executeTest(testFn) {
|
|
16
|
+
return (0, _1.executeTest)(this.pact, this.opts, testFn, this.cleanupFn);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
57
19
|
exports.InteractionWithResponse = InteractionWithResponse;
|
|
58
20
|
//# sourceMappingURL=interactionWithResponse.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interactionWithResponse.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithResponse.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"interactionWithResponse.js","sourceRoot":"","sources":["../../../../src/v4/http/interactionWithResponse.ts"],"names":[],"mappings":";;;AACA,wBAAgC;AAOhC,MAAa,uBAAuB;IAGxB;IACA;IACE;IAJZ,mCAAmC;IACnC,YACU,IAAkB,EAClB,IAAmB,EACjB,SAAqB;QAFvB,SAAI,GAAJ,IAAI,CAAc;QAClB,SAAI,GAAJ,IAAI,CAAe;QACjB,cAAS,GAAT,SAAS,CAAY;IAC9B,CAAC;IAEJ,KAAK,CAAC,WAAW,CAAI,MAAuB;QAC1C,OAAO,IAAA,cAAW,EAAC,IAAI,CAAC,IAAI,EAAE,IAAI,CAAC,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC;IACnE,CAAC;CACF;AAXD,0DAWC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import { ConsumerInteraction } from '@pact-foundation/pact-core';
|
|
2
|
-
import {
|
|
3
|
-
import { V4RequestBuilder } from './types';
|
|
1
|
+
import type { ConsumerInteraction } from '@pact-foundation/pact-core';
|
|
2
|
+
import type { Rules, TemplateHeaders, TemplateQuery } from '../../v3';
|
|
3
|
+
import type { V4RequestBuilder } from './types';
|
|
4
4
|
export declare class RequestBuilder implements V4RequestBuilder {
|
|
5
5
|
protected interaction: ConsumerInteraction;
|
|
6
6
|
constructor(interaction: ConsumerInteraction);
|
|
7
7
|
query(query: TemplateQuery): V4RequestBuilder;
|
|
8
8
|
headers(headers: TemplateHeaders): V4RequestBuilder;
|
|
9
9
|
jsonBody(body: unknown): V4RequestBuilder;
|
|
10
|
+
xmlBody(body: unknown): V4RequestBuilder;
|
|
10
11
|
binaryFile(contentType: string, file: string): V4RequestBuilder;
|
|
11
12
|
/**
|
|
12
13
|
* Sets the request body as multipart/form-data content.
|