@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
package/src/index.js
CHANGED
|
@@ -40,7 +40,7 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
40
40
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
41
41
|
};
|
|
42
42
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
43
|
-
exports.
|
|
43
|
+
exports.Matchers = exports.providerWithMetadata = exports.MessageProviderPact = exports.PactV2 = exports.MatchersV2 = void 0;
|
|
44
44
|
/**
|
|
45
45
|
* Exposes {@link Pact}
|
|
46
46
|
* @memberof Pact
|
|
@@ -53,33 +53,26 @@ exports.providerWithMetadata = exports.MessageProviderPact = exports.PactV2 = ex
|
|
|
53
53
|
* @memberof Pact
|
|
54
54
|
* @static
|
|
55
55
|
*/
|
|
56
|
-
|
|
56
|
+
const MatchersStar = __importStar(require("./dsl/matchers"));
|
|
57
57
|
exports.MatchersV2 = MatchersStar;
|
|
58
58
|
/**
|
|
59
|
-
* Exposes {@link
|
|
60
|
-
* To avoid polluting the root module's namespace, re-export
|
|
61
|
-
* Matchers as its own module
|
|
59
|
+
* Exposes {@link ApolloGraphQL}
|
|
62
60
|
* @memberof Pact
|
|
63
61
|
* @static
|
|
64
62
|
*/
|
|
65
|
-
|
|
66
|
-
Object.defineProperty(exports, "Matchers", { enumerable: true, get: function () { return v3_1.MatchersV3; } });
|
|
67
|
-
var httpPact_1 = require("./httpPact");
|
|
68
|
-
Object.defineProperty(exports, "PactV2", { enumerable: true, get: function () { return httpPact_1.Pact; } });
|
|
63
|
+
__exportStar(require("./dsl/apolloGraphql"), exports);
|
|
69
64
|
/**
|
|
70
|
-
* Exposes {@link
|
|
65
|
+
* Exposes {@link GraphQL}
|
|
71
66
|
* @memberof Pact
|
|
72
67
|
* @static
|
|
73
68
|
*/
|
|
74
|
-
__exportStar(require("./
|
|
69
|
+
__exportStar(require("./dsl/graphql"), exports);
|
|
75
70
|
/**
|
|
76
|
-
* Exposes {@link
|
|
71
|
+
* Exposes {@link Interaction}
|
|
77
72
|
* @memberof Pact
|
|
78
73
|
* @static
|
|
79
74
|
*/
|
|
80
|
-
|
|
81
|
-
Object.defineProperty(exports, "MessageProviderPact", { enumerable: true, get: function () { return messageProviderPact_1.MessageProviderPact; } });
|
|
82
|
-
Object.defineProperty(exports, "providerWithMetadata", { enumerable: true, get: function () { return messageProviderPact_1.providerWithMetadata; } });
|
|
75
|
+
__exportStar(require("./dsl/interaction"), exports);
|
|
83
76
|
/**
|
|
84
77
|
* Exposes {@link Message}
|
|
85
78
|
* @memberof Pact
|
|
@@ -87,46 +80,53 @@ Object.defineProperty(exports, "providerWithMetadata", { enumerable: true, get:
|
|
|
87
80
|
*/
|
|
88
81
|
__exportStar(require("./dsl/message"), exports);
|
|
89
82
|
/**
|
|
90
|
-
* Exposes {@link
|
|
83
|
+
* Exposes {@link MockService}
|
|
91
84
|
* @memberof Pact
|
|
92
85
|
* @static
|
|
93
86
|
*/
|
|
94
|
-
__exportStar(require("./dsl/
|
|
87
|
+
__exportStar(require("./dsl/mockService"), exports);
|
|
95
88
|
/**
|
|
96
|
-
* Exposes {@link
|
|
89
|
+
* Exposes {@link PactV2Options}
|
|
97
90
|
* @memberof Pact
|
|
98
91
|
* @static
|
|
99
92
|
*/
|
|
100
|
-
__exportStar(require("./dsl/
|
|
93
|
+
__exportStar(require("./dsl/options"), exports);
|
|
101
94
|
/**
|
|
102
|
-
* Exposes {@link
|
|
95
|
+
* Exposes {@link Verifier}
|
|
103
96
|
* @memberof Pact
|
|
104
97
|
* @static
|
|
105
98
|
*/
|
|
106
|
-
__exportStar(require("./dsl/
|
|
99
|
+
__exportStar(require("./dsl/verifier/verifier"), exports);
|
|
100
|
+
var httpPact_1 = require("./httpPact");
|
|
101
|
+
Object.defineProperty(exports, "PactV2", { enumerable: true, get: function () { return httpPact_1.Pact; } });
|
|
107
102
|
/**
|
|
108
|
-
* Exposes {@link
|
|
103
|
+
* Exposes {@link MessageConsumerPact}
|
|
109
104
|
* @memberof Pact
|
|
110
105
|
* @static
|
|
111
106
|
*/
|
|
112
|
-
__exportStar(require("./
|
|
107
|
+
__exportStar(require("./messageConsumerPact"), exports);
|
|
113
108
|
/**
|
|
114
|
-
* Exposes {@link
|
|
109
|
+
* Exposes {@link MessageProviderPact}
|
|
115
110
|
* @memberof Pact
|
|
116
111
|
* @static
|
|
117
112
|
*/
|
|
118
|
-
|
|
113
|
+
var messageProviderPact_1 = require("./messageProviderPact");
|
|
114
|
+
Object.defineProperty(exports, "MessageProviderPact", { enumerable: true, get: function () { return messageProviderPact_1.MessageProviderPact; } });
|
|
115
|
+
Object.defineProperty(exports, "providerWithMetadata", { enumerable: true, get: function () { return messageProviderPact_1.providerWithMetadata; } });
|
|
119
116
|
__exportStar(require("./v3"), exports);
|
|
120
117
|
/**
|
|
121
|
-
* Exposes {@link
|
|
118
|
+
* Exposes {@link Matchers}
|
|
119
|
+
* To avoid polluting the root module's namespace, re-export
|
|
120
|
+
* Matchers as its own module
|
|
122
121
|
* @memberof Pact
|
|
123
122
|
* @static
|
|
124
123
|
*/
|
|
125
|
-
|
|
124
|
+
var v3_1 = require("./v3");
|
|
125
|
+
Object.defineProperty(exports, "Matchers", { enumerable: true, get: function () { return v3_1.MatchersV3; } });
|
|
126
126
|
/**
|
|
127
|
-
* Exposes {@link
|
|
127
|
+
* Exposes {@link Pact}
|
|
128
128
|
* @memberof Pact
|
|
129
129
|
* @static
|
|
130
130
|
*/
|
|
131
|
-
__exportStar(require("./
|
|
131
|
+
__exportStar(require("./v4"), exports);
|
|
132
132
|
//# sourceMappingURL=index.js.map
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AACH,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH;;;;GAIG;AAEH;;;;;;GAMG;AACH,6DAA+C;AAElC,QAAA,UAAU,GAAG,YAAY,CAAC;AAEvC;;;;GAIG;AACH,sDAAoC;AACpC;;;;GAIG;AACH,gDAA8B;AAC9B;;;;GAIG;AACH,oDAAkC;AAElC;;;;GAIG;AACH,gDAA8B;AAC9B;;;;GAIG;AACH,oDAAkC;AAClC;;;;GAIG;AACH,gDAA8B;AAE9B;;;;GAIG;AACH,0DAAwC;AACxC,uCAA4C;AAAnC,kGAAA,IAAI,OAAU;AACvB;;;;GAIG;AACH,wDAAsC;AACtC;;;;GAIG;AACH,6DAG+B;AAF7B,0HAAA,mBAAmB,OAAA;AACnB,2HAAA,oBAAoB,OAAA;AAGtB,uCAAqB;AACrB;;;;;;GAMG;AACH,2BAA8C;AAArC,8FAAA,UAAU,OAAY;AAC/B;;;;GAIG;AACH,uCAAqB"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Message
|
|
3
3
|
*/
|
|
4
|
-
import { AnyJson } from './common/jsonTypes';
|
|
5
|
-
import {
|
|
6
|
-
import { MessageConsumerOptions } from './dsl/options';
|
|
4
|
+
import type { AnyJson } from './common/jsonTypes';
|
|
5
|
+
import type { Message, MessageConsumer, Metadata, ProviderState } from './dsl/message';
|
|
6
|
+
import type { MessageConsumerOptions } from './dsl/options';
|
|
7
7
|
/**
|
|
8
8
|
* A Message Consumer is analogous to a Provider in the HTTP Interaction model.
|
|
9
9
|
* It is the receiver of an interaction, and needs to be able to handle whatever
|
|
@@ -80,5 +80,5 @@ export declare class MessageConsumerPact {
|
|
|
80
80
|
*/
|
|
81
81
|
json(): Message;
|
|
82
82
|
}
|
|
83
|
-
export declare function synchronousBodyHandler<R>(handler: (body:
|
|
84
|
-
export declare function asynchronousBodyHandler<R>(handler: (body:
|
|
83
|
+
export declare function synchronousBodyHandler<R, B extends AnyJson | Buffer = AnyJson | Buffer>(handler: (body: B) => R): MessageConsumer;
|
|
84
|
+
export declare function asynchronousBodyHandler<R, B extends AnyJson | Buffer = AnyJson | Buffer>(handler: (body: B) => Promise<R>): MessageConsumer;
|
|
@@ -42,15 +42,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
42
42
|
exports.MessageConsumerPact = void 0;
|
|
43
43
|
exports.synchronousBodyHandler = synchronousBodyHandler;
|
|
44
44
|
exports.asynchronousBodyHandler = asynchronousBodyHandler;
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
45
|
+
const pact_core_1 = __importStar(require("@pact-foundation/pact-core"));
|
|
46
|
+
const lodash_1 = require("lodash");
|
|
47
|
+
const ramda_1 = require("ramda");
|
|
48
|
+
const package_json_1 = require("../package.json");
|
|
49
|
+
const logger_1 = __importStar(require("./common/logger"));
|
|
50
|
+
const spec_1 = require("./common/spec");
|
|
51
|
+
const configurationError_1 = __importDefault(require("./errors/configurationError"));
|
|
52
|
+
const v3_1 = require("./v3");
|
|
53
|
+
const DEFAULT_PACT_DIR = './pacts';
|
|
54
54
|
var ContentType;
|
|
55
55
|
(function (ContentType) {
|
|
56
56
|
ContentType[ContentType["JSON"] = 0] = "JSON";
|
|
@@ -62,10 +62,13 @@ var ContentType;
|
|
|
62
62
|
* It is the receiver of an interaction, and needs to be able to handle whatever
|
|
63
63
|
* request was provided.
|
|
64
64
|
*/
|
|
65
|
-
|
|
66
|
-
|
|
65
|
+
class MessageConsumerPact {
|
|
66
|
+
config;
|
|
67
|
+
state = {};
|
|
68
|
+
pact;
|
|
69
|
+
message;
|
|
70
|
+
constructor(config) {
|
|
67
71
|
this.config = config;
|
|
68
|
-
this.state = {};
|
|
69
72
|
this.pact = (0, pact_core_1.makeConsumerAsyncMessagePact)(config.consumer, config.provider, (0, spec_1.numberToSpec)(config.spec, v3_1.SpecificationVersion.SPECIFICATION_VERSION_V3), config.logLevel);
|
|
70
73
|
this.pact.addMetadata('pact-js', 'version', package_json_1.version);
|
|
71
74
|
this.message = this.pact.newMessage('');
|
|
@@ -80,7 +83,7 @@ var MessageConsumerPact = /** @class */ (function () {
|
|
|
80
83
|
* @param {string} state - The state of the provider.
|
|
81
84
|
* @returns {Message} MessageConsumer
|
|
82
85
|
*/
|
|
83
|
-
|
|
86
|
+
given(state) {
|
|
84
87
|
if (typeof state === 'string') {
|
|
85
88
|
this.message.given(state);
|
|
86
89
|
}
|
|
@@ -88,20 +91,20 @@ var MessageConsumerPact = /** @class */ (function () {
|
|
|
88
91
|
this.message.givenWithParams(state.name, JSON.stringify(state.params));
|
|
89
92
|
}
|
|
90
93
|
return this;
|
|
91
|
-
}
|
|
94
|
+
}
|
|
92
95
|
/**
|
|
93
96
|
* A free style description of the Message.
|
|
94
97
|
*
|
|
95
98
|
* @param {string} description - A description of the Message to be received
|
|
96
99
|
* @returns {Message} MessageConsumer
|
|
97
100
|
*/
|
|
98
|
-
|
|
101
|
+
expectsToReceive(description) {
|
|
99
102
|
if ((0, lodash_1.isEmpty)(description)) {
|
|
100
103
|
throw new configurationError_1.default('You must provide a description for the Message.');
|
|
101
104
|
}
|
|
102
105
|
this.message.expectsToReceive(description);
|
|
103
106
|
return this;
|
|
104
|
-
}
|
|
107
|
+
}
|
|
105
108
|
/**
|
|
106
109
|
* The JSON object to be received by the message consumer.
|
|
107
110
|
*
|
|
@@ -111,14 +114,14 @@ var MessageConsumerPact = /** @class */ (function () {
|
|
|
111
114
|
* @param {string} content - A description of the Message to be received
|
|
112
115
|
* @returns {Message} MessageConsumer
|
|
113
116
|
*/
|
|
114
|
-
|
|
117
|
+
withContent(content) {
|
|
115
118
|
if ((0, lodash_1.isEmpty)(content)) {
|
|
116
119
|
throw new configurationError_1.default('You must provide a valid JSON document or primitive for the Message.');
|
|
117
120
|
}
|
|
118
121
|
this.message.withContents(JSON.stringify(content), 'application/json');
|
|
119
122
|
this.state.contentType = ContentType.JSON;
|
|
120
123
|
return this;
|
|
121
|
-
}
|
|
124
|
+
}
|
|
122
125
|
/**
|
|
123
126
|
* The text content to be received by the message consumer.
|
|
124
127
|
*
|
|
@@ -127,11 +130,11 @@ var MessageConsumerPact = /** @class */ (function () {
|
|
|
127
130
|
* @param {string} content - A description of the Message to be received
|
|
128
131
|
* @returns {Message} MessageConsumer
|
|
129
132
|
*/
|
|
130
|
-
|
|
133
|
+
withTextContent(content, contentType) {
|
|
131
134
|
this.message.withContents(content, contentType);
|
|
132
135
|
this.state.contentType = ContentType.STRING;
|
|
133
136
|
return this;
|
|
134
|
-
}
|
|
137
|
+
}
|
|
135
138
|
/**
|
|
136
139
|
* The binary content to be received by the message consumer.
|
|
137
140
|
*
|
|
@@ -141,76 +144,78 @@ var MessageConsumerPact = /** @class */ (function () {
|
|
|
141
144
|
* @param {String} contenttype - The mime type of the content to expect
|
|
142
145
|
* @returns {Message} MessageConsumer
|
|
143
146
|
*/
|
|
144
|
-
|
|
147
|
+
withBinaryContent(content, contentType) {
|
|
145
148
|
this.message.withBinaryContents(content, contentType);
|
|
146
149
|
this.state.contentType = ContentType.BINARY;
|
|
147
150
|
return this;
|
|
148
|
-
}
|
|
151
|
+
}
|
|
149
152
|
/**
|
|
150
153
|
* Message metadata.
|
|
151
154
|
*
|
|
152
155
|
* @param {string} metadata -
|
|
153
156
|
* @returns {Message} MessageConsumer
|
|
154
157
|
*/
|
|
155
|
-
|
|
156
|
-
var _this = this;
|
|
158
|
+
withMetadata(metadata) {
|
|
157
159
|
if ((0, lodash_1.isEmpty)(metadata)) {
|
|
158
160
|
throw new configurationError_1.default('You must provide valid metadata for the Message, or none at all');
|
|
159
161
|
}
|
|
160
|
-
(0, ramda_1.forEachObjIndexed)(
|
|
161
|
-
|
|
162
|
+
(0, ramda_1.forEachObjIndexed)((v, k) => {
|
|
163
|
+
this.message.withMetadata(`${k}`, JSON.stringify(v));
|
|
162
164
|
}, metadata);
|
|
163
165
|
return this;
|
|
164
|
-
}
|
|
166
|
+
}
|
|
165
167
|
/**
|
|
166
168
|
* Creates a new Pact _message_ interaction to build a testable interaction.
|
|
167
169
|
*
|
|
168
170
|
* @param handler A message handler, that must be able to consume the given Message
|
|
169
171
|
* @returns {Promise}
|
|
170
172
|
*/
|
|
171
|
-
|
|
172
|
-
var _this = this;
|
|
173
|
+
verify(handler) {
|
|
173
174
|
logger_1.default.info('Verifying message');
|
|
174
175
|
return handler(this.reifiedContent())
|
|
175
|
-
.then(
|
|
176
|
-
|
|
177
|
-
_this.pact.writePactFile((_a = _this.config.dir) !== null && _a !== void 0 ? _a : DEFAULT_PACT_DIR, _this.config.pactfileWriteMode !== 'overwrite');
|
|
176
|
+
.then(() => {
|
|
177
|
+
this.pact.writePactFile(this.config.dir ?? DEFAULT_PACT_DIR, this.config.pactfileWriteMode !== 'overwrite');
|
|
178
178
|
})
|
|
179
|
-
.finally(
|
|
180
|
-
|
|
181
|
-
|
|
179
|
+
.finally(() => {
|
|
180
|
+
this.message = this.pact.newMessage('');
|
|
181
|
+
this.state = {};
|
|
182
182
|
});
|
|
183
|
-
}
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
logger_1.default.debug(
|
|
187
|
-
|
|
183
|
+
}
|
|
184
|
+
reifiedContent() {
|
|
185
|
+
const raw = this.message.reifyMessage();
|
|
186
|
+
logger_1.default.debug(`reified message raw: raw`);
|
|
187
|
+
const reified = JSON.parse(raw);
|
|
188
188
|
if (this.state.contentType === ContentType.BINARY) {
|
|
189
189
|
reified.contents = Buffer.from(reified.contents, 'base64');
|
|
190
190
|
}
|
|
191
|
-
logger_1.default.debug(
|
|
191
|
+
logger_1.default.debug(`rehydrated message body into correct type: ${reified.contents}`);
|
|
192
192
|
return reified;
|
|
193
|
-
}
|
|
193
|
+
}
|
|
194
194
|
/**
|
|
195
195
|
* Returns the Message object created.
|
|
196
196
|
*
|
|
197
197
|
* @returns {Message}
|
|
198
198
|
*/
|
|
199
|
-
|
|
199
|
+
json() {
|
|
200
200
|
return this.state;
|
|
201
|
-
}
|
|
202
|
-
|
|
203
|
-
}());
|
|
201
|
+
}
|
|
202
|
+
}
|
|
204
203
|
exports.MessageConsumerPact = MessageConsumerPact;
|
|
205
204
|
// TODO: create more basic adapters for API handlers
|
|
206
205
|
// bodyHandler takes a synchronous function and returns
|
|
207
|
-
// a wrapped function that accepts a Message and returns a Promise
|
|
206
|
+
// a wrapped function that accepts a Message and returns a Promise.
|
|
207
|
+
//
|
|
208
|
+
// The body type defaults to `AnyJson | Buffer` (the runtime type of
|
|
209
|
+
// `m.contents`), but callers may narrow it to a custom shape (e.g. an
|
|
210
|
+
// interface describing the JSON they expect to receive) by supplying the
|
|
211
|
+
// `B` type parameter. The narrowing is a TypeScript-only assertion; the
|
|
212
|
+
// runtime value is still whatever the producer sent.
|
|
208
213
|
function synchronousBodyHandler(handler) {
|
|
209
|
-
return
|
|
210
|
-
|
|
211
|
-
return new Promise(
|
|
214
|
+
return (m) => {
|
|
215
|
+
const body = m.contents;
|
|
216
|
+
return new Promise((resolve, reject) => {
|
|
212
217
|
try {
|
|
213
|
-
|
|
218
|
+
const res = handler(body);
|
|
214
219
|
resolve(res);
|
|
215
220
|
}
|
|
216
221
|
catch (e) {
|
|
@@ -220,9 +225,10 @@ function synchronousBodyHandler(handler) {
|
|
|
220
225
|
};
|
|
221
226
|
}
|
|
222
227
|
// bodyHandler takes an asynchronous (promisified) function and returns
|
|
223
|
-
// a wrapped function that accepts a Message and returns a Promise
|
|
228
|
+
// a wrapped function that accepts a Message and returns a Promise.
|
|
229
|
+
// See `synchronousBodyHandler` for the rationale behind the `B` parameter.
|
|
224
230
|
// TODO: move this into its own package and re-export?
|
|
225
231
|
function asynchronousBodyHandler(handler) {
|
|
226
|
-
return
|
|
232
|
+
return (m) => handler(m.contents);
|
|
227
233
|
}
|
|
228
234
|
//# sourceMappingURL=messageConsumerPact.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageConsumerPact.js","sourceRoot":"","sources":["../../src/messageConsumerPact.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"messageConsumerPact.js","sourceRoot":"","sources":["../../src/messageConsumerPact.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA0OH,wDAgBC;AAMD,0DAKC;AAnQD,wEAIoC;AACpC,mCAAiC;AACjC,iCAA0C;AAC1C,kDAAgE;AAEhE,0DAAsD;AACtD,wCAA6C;AAS7C,qFAA6D;AAC7D,6BAA4C;AAE5C,MAAM,gBAAgB,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ED,gBAAM,CAAC,KAAK,CACV,8CAA8C,OAAO,CAAC,QAAQ,EAAE,CACjE,CAAC;QAEF,OAAO,OAAO,CAAC;IACjB,CAAC;IAED;;;;OAIG;IACI,IAAI;QACT,OAAO,IAAI,CAAC,KAAgB,CAAC;IAC/B,CAAC;CACF;AArLD,kDAqLC;AAED,oDAAoD;AAEpD,uDAAuD;AACvD,mEAAmE;AACnE,EAAE;AACF,oEAAoE;AACpE,sEAAsE;AACtE,yEAAyE;AACzE,wEAAwE;AACxE,qDAAqD;AACrD,SAAgB,sBAAsB,CAGpC,OAAuB;IACvB,OAAO,CAAC,CAAkB,EAAc,EAAE;QACxC,MAAM,IAAI,GAAG,CAAC,CAAC,QAAa,CAAC;QAE7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YACrC,IAAI,CAAC;gBACH,MAAM,GAAG,GAAG,OAAO,CAAC,IAAI,CAAC,CAAC;gBAC1B,OAAO,CAAC,GAAG,CAAC,CAAC;YACf,CAAC;YAAC,OAAO,CAAC,EAAE,CAAC;gBACX,MAAM,CAAC,CAAC,CAAC,CAAC;YACZ,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC;AACJ,CAAC;AAED,uEAAuE;AACvE,mEAAmE;AACnE,2EAA2E;AAC3E,sDAAsD;AACtD,SAAgB,uBAAuB,CAGrC,OAAgC;IAChC,OAAO,CAAC,CAAkB,EAAE,EAAE,CAAC,OAAO,CAAC,CAAC,CAAC,QAAa,CAAC,CAAC;AAC1D,CAAC"}
|
|
@@ -1,146 +1,104 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || (function () {
|
|
19
|
-
var ownKeys = function(o) {
|
|
20
|
-
ownKeys = Object.getOwnPropertyNames || function (o) {
|
|
21
|
-
var ar = [];
|
|
22
|
-
for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
|
|
23
|
-
return ar;
|
|
24
|
-
};
|
|
25
|
-
return ownKeys(o);
|
|
26
|
-
};
|
|
27
|
-
return function (mod) {
|
|
28
|
-
if (mod && mod.__esModule) return mod;
|
|
29
|
-
var result = {};
|
|
30
|
-
if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
|
|
31
|
-
__setModuleDefault(result, mod);
|
|
32
|
-
return result;
|
|
33
|
-
};
|
|
34
|
-
})();
|
|
35
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
36
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
37
|
-
};
|
|
38
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
chai.use(sinon_chai_1.default);
|
|
44
|
-
chai.use(chai_as_promised_1.default);
|
|
45
|
-
var expect = chai.expect;
|
|
46
|
-
describe('MessageConsumer', function () {
|
|
47
|
-
var consumer;
|
|
48
|
-
beforeEach(function () {
|
|
3
|
+
const messageConsumerPact_1 = require("./messageConsumerPact");
|
|
4
|
+
describe('MessageConsumer', () => {
|
|
5
|
+
let consumer;
|
|
6
|
+
beforeEach(() => {
|
|
49
7
|
consumer = new messageConsumerPact_1.MessageConsumerPact({
|
|
50
8
|
consumer: 'myconsumer',
|
|
51
9
|
provider: 'myprovider',
|
|
52
10
|
});
|
|
53
11
|
});
|
|
54
|
-
|
|
12
|
+
const testMessage = {
|
|
55
13
|
contents: {
|
|
56
14
|
foo: 'bar',
|
|
57
15
|
},
|
|
58
16
|
};
|
|
59
|
-
describe('#constructor',
|
|
60
|
-
it('creates a Consumer when all mandatory parameters are provided',
|
|
61
|
-
expect(consumer).
|
|
62
|
-
expect(consumer).
|
|
17
|
+
describe('#constructor', () => {
|
|
18
|
+
it('creates a Consumer when all mandatory parameters are provided', () => {
|
|
19
|
+
expect(consumer).toBeTypeOf('object');
|
|
20
|
+
expect(typeof consumer.verify).toBe('function');
|
|
63
21
|
});
|
|
64
22
|
});
|
|
65
|
-
describe('#dsl',
|
|
66
|
-
describe('when an empty description has been given',
|
|
67
|
-
it('it should throw an error',
|
|
68
|
-
expect(
|
|
23
|
+
describe('#dsl', () => {
|
|
24
|
+
describe('when an empty description has been given', () => {
|
|
25
|
+
it('it should throw an error', () => {
|
|
26
|
+
expect(() => {
|
|
69
27
|
consumer.expectsToReceive('');
|
|
70
|
-
}).
|
|
28
|
+
}).toThrow(Error);
|
|
71
29
|
});
|
|
72
30
|
});
|
|
73
|
-
describe('when an empty content object has been given',
|
|
74
|
-
it('it should throw an error',
|
|
75
|
-
expect(
|
|
31
|
+
describe('when an empty content object has been given', () => {
|
|
32
|
+
it('it should throw an error', () => {
|
|
33
|
+
expect(() => {
|
|
76
34
|
consumer.withContent({});
|
|
77
|
-
}).
|
|
35
|
+
}).toThrow(Error);
|
|
78
36
|
});
|
|
79
37
|
});
|
|
80
|
-
describe('when an empty metadata object has been given',
|
|
81
|
-
it('it should throw an error',
|
|
82
|
-
expect(
|
|
38
|
+
describe('when an empty metadata object has been given', () => {
|
|
39
|
+
it('it should throw an error', () => {
|
|
40
|
+
expect(() => {
|
|
83
41
|
consumer.withMetadata({});
|
|
84
|
-
}).
|
|
42
|
+
}).toThrow(Error);
|
|
85
43
|
});
|
|
86
44
|
});
|
|
87
45
|
});
|
|
88
|
-
describe('#verify',
|
|
89
|
-
describe('when given a valid handler and message',
|
|
90
|
-
it('verifies the consumer message',
|
|
91
|
-
|
|
46
|
+
describe('#verify', () => {
|
|
47
|
+
describe('when given a valid handler and message', () => {
|
|
48
|
+
it('verifies the consumer message', async () => {
|
|
49
|
+
const stubbedConsumer = new messageConsumerPact_1.MessageConsumerPact({
|
|
92
50
|
consumer: 'myconsumer',
|
|
93
51
|
provider: 'myprovider',
|
|
94
52
|
});
|
|
95
|
-
|
|
53
|
+
// biome-ignore lint/suspicious/noExplicitAny: accessing private getServiceFactory method for test stubbing
|
|
54
|
+
const stub = stubbedConsumer;
|
|
96
55
|
// Stub out service factory
|
|
97
|
-
stub.getServiceFactory =
|
|
98
|
-
createMessage:
|
|
99
|
-
});
|
|
56
|
+
stub.getServiceFactory = () => ({
|
|
57
|
+
createMessage: () => Promise.resolve('message created'),
|
|
58
|
+
});
|
|
100
59
|
stubbedConsumer
|
|
101
60
|
.given('some state')
|
|
102
61
|
.expectsToReceive('A message about something')
|
|
103
62
|
.withContent({ foo: 'bar' })
|
|
104
63
|
.withMetadata({ baz: 'bat' });
|
|
105
|
-
|
|
106
|
-
.eventually.be.fulfilled;
|
|
64
|
+
await stubbedConsumer.verify(() => Promise.resolve('yay!'));
|
|
107
65
|
});
|
|
108
66
|
});
|
|
109
67
|
});
|
|
110
|
-
describe('handler transformers',
|
|
111
|
-
describe('#asynchronousbodyHandler',
|
|
112
|
-
describe('when given a function that succeeds',
|
|
113
|
-
it('returns a Handler object that returns a completed promise',
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
68
|
+
describe('handler transformers', () => {
|
|
69
|
+
describe('#asynchronousbodyHandler', () => {
|
|
70
|
+
describe('when given a function that succeeds', () => {
|
|
71
|
+
it('returns a Handler object that returns a completed promise', async () => {
|
|
72
|
+
const failFn = () => Promise.resolve('yay!');
|
|
73
|
+
const hFn = (0, messageConsumerPact_1.asynchronousBodyHandler)(failFn);
|
|
74
|
+
await hFn(testMessage);
|
|
117
75
|
});
|
|
118
76
|
});
|
|
119
|
-
describe('when given a function that throws an Exception',
|
|
120
|
-
it('returns a Handler object that returns a rejected promise',
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
77
|
+
describe('when given a function that throws an Exception', () => {
|
|
78
|
+
it('returns a Handler object that returns a rejected promise', async () => {
|
|
79
|
+
const failFn = () => Promise.reject(new Error('fail'));
|
|
80
|
+
const hFn = (0, messageConsumerPact_1.asynchronousBodyHandler)(failFn);
|
|
81
|
+
await expect(hFn(testMessage)).rejects.toThrow();
|
|
124
82
|
});
|
|
125
83
|
});
|
|
126
84
|
});
|
|
127
|
-
describe('#synchronousbodyHandler',
|
|
128
|
-
describe('when given a function that succeeds',
|
|
129
|
-
it('returns a Handler object that returns a completed promise',
|
|
130
|
-
|
|
85
|
+
describe('#synchronousbodyHandler', () => {
|
|
86
|
+
describe('when given a function that succeeds', () => {
|
|
87
|
+
it('returns a Handler object that returns a completed promise', async () => {
|
|
88
|
+
const failFn = () => {
|
|
131
89
|
/* do nothing! */
|
|
132
90
|
};
|
|
133
|
-
|
|
134
|
-
|
|
91
|
+
const hFn = (0, messageConsumerPact_1.synchronousBodyHandler)(failFn);
|
|
92
|
+
await hFn(testMessage);
|
|
135
93
|
});
|
|
136
94
|
});
|
|
137
|
-
describe('when given a function that throws an Exception',
|
|
138
|
-
it('returns a Handler object that returns a rejected promise',
|
|
139
|
-
|
|
95
|
+
describe('when given a function that throws an Exception', () => {
|
|
96
|
+
it('returns a Handler object that returns a rejected promise', async () => {
|
|
97
|
+
const failFn = () => {
|
|
140
98
|
throw new Error('fail');
|
|
141
99
|
};
|
|
142
|
-
|
|
143
|
-
|
|
100
|
+
const hFn = (0, messageConsumerPact_1.synchronousBodyHandler)(failFn);
|
|
101
|
+
await expect(hFn(testMessage)).rejects.toThrow();
|
|
144
102
|
});
|
|
145
103
|
});
|
|
146
104
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messageConsumerPact.spec.js","sourceRoot":"","sources":["../../src/messageConsumerPact.spec.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"messageConsumerPact.spec.js","sourceRoot":"","sources":["../../src/messageConsumerPact.spec.ts"],"names":[],"mappings":";;AACA,+DAI+B;AAE/B,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC/B,IAAI,QAA6B,CAAC;IAElC,UAAU,CAAC,GAAG,EAAE;QACd,QAAQ,GAAG,IAAI,yCAAmB,CAAC;YACjC,QAAQ,EAAE,YAAY;YACtB,QAAQ,EAAE,YAAY;SACvB,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,MAAM,WAAW,GAAoB;QACnC,QAAQ,EAAE;YACR,GAAG,EAAE,KAAK;SACX;KACF,CAAC;IAEF,QAAQ,CAAC,cAAc,EAAE,GAAG,EAAE;QAC5B,EAAE,CAAC,+DAA+D,EAAE,GAAG,EAAE;YACvE,MAAM,CAAC,QAAQ,CAAC,CAAC,UAAU,CAAC,QAAQ,CAAC,CAAC;YACtC,MAAM,CAAC,OAAO,QAAQ,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;QAClD,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IAEH,QAAQ,CAAC,MAAM,EAAE,GAAG,EAAE;QACpB,QAAQ,CAAC,0CAA0C,EAAE,GAAG,EAAE;YACxD,EAAE,CAAC,0BAA0B,EAAE,GAAG,EAAE;gBAClC,MAAM,CAAC,GAAG,EAAE;oBACV,QAAQ,CAAC,gBAAgB,CAAC,EAAE,CAAC,CAAC;gBAChC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;YACpB,CAA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,KAAK,IAAI,EAAE;oBACzE,MAAM,MAAM,GAAG,GAAG,EAAE;wBAClB,iBAAiB;oBACnB,CAAC,CAAC;oBACF,MAAM,GAAG,GAAG,IAAA,4CAAsB,EAAC,MAAM,CAAC,CAAC;oBAE3C,MAAM,GAAG,CAAC,WAAW,CAAC,CAAC;gBACzB,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;YAEH,QAAQ,CAAC,gDAAgD,EAAE,GAAG,EAAE;gBAC9D,EAAE,CAAC,0DAA0D,EAAE,KAAK,IAAI,EAAE;oBACxE,MAAM,MAAM,GAAG,GAAG,EAAE;wBAClB,MAAM,IAAI,KAAK,CAAC,MAAM,CAAC,CAAC;oBAC1B,CAAC,CAAC;oBACF,MAAM,GAAG,GAAG,IAAA,4CAAsB,EAAC,MAAM,CAAC,CAAC;oBAE3C,MAAM,MAAM,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,CAAC;gBACnD,CAAC,CAAC,CAAC;YACL,CAAC,CAAC,CAAC;QACL,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module Message
|
|
3
3
|
*/
|
|
4
|
-
import http from 'http';
|
|
5
|
-
import { MessageProvider } from './dsl/message';
|
|
6
|
-
import { PactMessageProviderOptions } from './dsl/options';
|
|
4
|
+
import http from 'node:http';
|
|
5
|
+
import type { MessageProvider } from './dsl/message';
|
|
6
|
+
import type { PactMessageProviderOptions } from './dsl/options';
|
|
7
7
|
export declare const waitForServerReady: (server: http.Server) => Promise<http.Server>;
|
|
8
8
|
export declare const setupProxyServer: (app: (request: http.IncomingMessage, response: http.ServerResponse) => void) => http.Server;
|
|
9
9
|
export declare const providerWithMetadata: (provider: MessageProvider, metadata: Record<string, string>) => MessageProvider;
|