@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/v3/matchers.spec.js
CHANGED
|
@@ -1,15 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __assign = (this && this.__assign) || function () {
|
|
3
|
-
__assign = Object.assign || function(t) {
|
|
4
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
-
s = arguments[i];
|
|
6
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
-
t[p] = s[p];
|
|
8
|
-
}
|
|
9
|
-
return t;
|
|
10
|
-
};
|
|
11
|
-
return __assign.apply(this, arguments);
|
|
12
|
-
};
|
|
13
2
|
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
14
3
|
if (k2 === undefined) k2 = k;
|
|
15
4
|
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
@@ -44,27 +33,25 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
44
33
|
};
|
|
45
34
|
})();
|
|
46
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
it('compiles with nested examples from issue 1054', function () {
|
|
52
|
-
var f = { a: 'working example' };
|
|
36
|
+
const MatchersV3 = __importStar(require("./matchers"));
|
|
37
|
+
describe('V3 Matchers', () => {
|
|
38
|
+
it('compiles with nested examples from issue 1054', () => {
|
|
39
|
+
const f = { a: 'working example' };
|
|
53
40
|
MatchersV3.like(f);
|
|
54
|
-
MatchersV3.like(
|
|
41
|
+
MatchersV3.like({ ...f });
|
|
55
42
|
MatchersV3.like(Object.freeze(f));
|
|
56
|
-
|
|
43
|
+
const r = { id: 'some guid', foo: { a: 'example' } };
|
|
57
44
|
MatchersV3.like(r);
|
|
58
|
-
MatchersV3.like(
|
|
45
|
+
MatchersV3.like({ ...r });
|
|
59
46
|
MatchersV3.like(Object.freeze(f));
|
|
60
47
|
MatchersV3.reify(r);
|
|
61
48
|
});
|
|
62
|
-
describe('#like',
|
|
63
|
-
it('returns a JSON representation of a like matcher',
|
|
64
|
-
|
|
49
|
+
describe('#like', () => {
|
|
50
|
+
it('returns a JSON representation of a like matcher', () => {
|
|
51
|
+
const result = MatchersV3.like({
|
|
65
52
|
a: 'b',
|
|
66
53
|
});
|
|
67
|
-
expect(result).
|
|
54
|
+
expect(result).toEqual({
|
|
68
55
|
'pact:matcher:type': 'type',
|
|
69
56
|
value: {
|
|
70
57
|
a: 'b',
|
|
@@ -72,12 +59,12 @@ describe('V3 Matchers', function () {
|
|
|
72
59
|
});
|
|
73
60
|
});
|
|
74
61
|
});
|
|
75
|
-
describe('#eachKeylike',
|
|
76
|
-
it('returns a JSON representation of an eachKeyLike matcher',
|
|
77
|
-
|
|
62
|
+
describe('#eachKeylike', () => {
|
|
63
|
+
it('returns a JSON representation of an eachKeyLike matcher', () => {
|
|
64
|
+
const result = MatchersV3.eachKeyLike('004', {
|
|
78
65
|
id: '004',
|
|
79
66
|
});
|
|
80
|
-
expect(result).
|
|
67
|
+
expect(result).toEqual({
|
|
81
68
|
'pact:matcher:type': 'values',
|
|
82
69
|
value: {
|
|
83
70
|
'004': {
|
|
@@ -87,13 +74,13 @@ describe('V3 Matchers', function () {
|
|
|
87
74
|
});
|
|
88
75
|
});
|
|
89
76
|
});
|
|
90
|
-
describe('#eachLike',
|
|
91
|
-
describe('with no min',
|
|
92
|
-
it('returns a JSON representation of an eachLike matcher',
|
|
93
|
-
|
|
77
|
+
describe('#eachLike', () => {
|
|
78
|
+
describe('with no min', () => {
|
|
79
|
+
it('returns a JSON representation of an eachLike matcher', () => {
|
|
80
|
+
const result = MatchersV3.eachLike({
|
|
94
81
|
a: 'b',
|
|
95
82
|
});
|
|
96
|
-
expect(result).
|
|
83
|
+
expect(result).toEqual({
|
|
97
84
|
min: 1,
|
|
98
85
|
'pact:matcher:type': 'type',
|
|
99
86
|
value: [
|
|
@@ -104,12 +91,12 @@ describe('V3 Matchers', function () {
|
|
|
104
91
|
});
|
|
105
92
|
});
|
|
106
93
|
});
|
|
107
|
-
describe('with min',
|
|
108
|
-
it('returns a JSON representation of an eachLike matcher',
|
|
109
|
-
|
|
94
|
+
describe('with min', () => {
|
|
95
|
+
it('returns a JSON representation of an eachLike matcher', () => {
|
|
96
|
+
const result = MatchersV3.eachLike({
|
|
110
97
|
a: 'b',
|
|
111
98
|
}, 3);
|
|
112
|
-
expect(result).
|
|
99
|
+
expect(result).toEqual({
|
|
113
100
|
min: 3,
|
|
114
101
|
'pact:matcher:type': 'type',
|
|
115
102
|
value: [
|
|
@@ -127,13 +114,13 @@ describe('V3 Matchers', function () {
|
|
|
127
114
|
});
|
|
128
115
|
});
|
|
129
116
|
});
|
|
130
|
-
describe('#atLeastOneLike',
|
|
131
|
-
describe('with no examples',
|
|
132
|
-
it('returns a JSON representation of an atLeastOneLike matcher',
|
|
133
|
-
|
|
117
|
+
describe('#atLeastOneLike', () => {
|
|
118
|
+
describe('with no examples', () => {
|
|
119
|
+
it('returns a JSON representation of an atLeastOneLike matcher', () => {
|
|
120
|
+
const result = MatchersV3.atLeastOneLike({
|
|
134
121
|
a: 'b',
|
|
135
122
|
});
|
|
136
|
-
expect(result).
|
|
123
|
+
expect(result).toEqual({
|
|
137
124
|
'pact:matcher:type': 'type',
|
|
138
125
|
min: 1,
|
|
139
126
|
value: [
|
|
@@ -144,12 +131,12 @@ describe('V3 Matchers', function () {
|
|
|
144
131
|
});
|
|
145
132
|
});
|
|
146
133
|
});
|
|
147
|
-
describe('when provided examples',
|
|
148
|
-
it('returns a JSON representation of an atLeastOneLike matcher with the correct number of examples',
|
|
149
|
-
|
|
134
|
+
describe('when provided examples', () => {
|
|
135
|
+
it('returns a JSON representation of an atLeastOneLike matcher with the correct number of examples', () => {
|
|
136
|
+
const result = MatchersV3.atLeastOneLike({
|
|
150
137
|
a: 'b',
|
|
151
138
|
}, 4);
|
|
152
|
-
expect(result).
|
|
139
|
+
expect(result).toEqual({
|
|
153
140
|
'pact:matcher:type': 'type',
|
|
154
141
|
min: 1,
|
|
155
142
|
value: [{ a: 'b' }, { a: 'b' }, { a: 'b' }, { a: 'b' }],
|
|
@@ -157,71 +144,71 @@ describe('V3 Matchers', function () {
|
|
|
157
144
|
});
|
|
158
145
|
});
|
|
159
146
|
});
|
|
160
|
-
describe('#atLeastLike',
|
|
161
|
-
describe('with no examples',
|
|
162
|
-
it('returns a JSON representation of an atLeastLike matcher',
|
|
163
|
-
|
|
147
|
+
describe('#atLeastLike', () => {
|
|
148
|
+
describe('with no examples', () => {
|
|
149
|
+
it('returns a JSON representation of an atLeastLike matcher', () => {
|
|
150
|
+
const result = MatchersV3.atLeastLike({
|
|
164
151
|
a: 'b',
|
|
165
152
|
}, 2);
|
|
166
|
-
expect(result).
|
|
153
|
+
expect(result).toEqual({
|
|
167
154
|
'pact:matcher:type': 'type',
|
|
168
155
|
min: 2,
|
|
169
156
|
value: [{ a: 'b' }, { a: 'b' }],
|
|
170
157
|
});
|
|
171
158
|
});
|
|
172
159
|
});
|
|
173
|
-
describe('when provided examples',
|
|
174
|
-
it('returns a JSON representation of an atLeastLike matcher with the correct number of examples',
|
|
175
|
-
|
|
160
|
+
describe('when provided examples', () => {
|
|
161
|
+
it('returns a JSON representation of an atLeastLike matcher with the correct number of examples', () => {
|
|
162
|
+
const result = MatchersV3.atLeastLike({
|
|
176
163
|
a: 'b',
|
|
177
164
|
}, 2, 4);
|
|
178
|
-
expect(result).
|
|
165
|
+
expect(result).toEqual({
|
|
179
166
|
'pact:matcher:type': 'type',
|
|
180
167
|
min: 2,
|
|
181
168
|
value: [{ a: 'b' }, { a: 'b' }, { a: 'b' }, { a: 'b' }],
|
|
182
169
|
});
|
|
183
170
|
});
|
|
184
171
|
});
|
|
185
|
-
it('throws an error if the number of examples is less than the minimum',
|
|
186
|
-
expect(
|
|
172
|
+
it('throws an error if the number of examples is less than the minimum', () => {
|
|
173
|
+
expect(() => MatchersV3.atLeastLike({ a: 'b' }, 4, 2)).toThrow('atLeastLike has a minimum of 4 but 2 elements were requested. Make sure the count is greater than or equal to the min.');
|
|
187
174
|
});
|
|
188
175
|
});
|
|
189
|
-
describe('#atMostLike',
|
|
190
|
-
describe('with no examples',
|
|
191
|
-
it('returns a JSON representation of an atMostLike matcher',
|
|
192
|
-
|
|
176
|
+
describe('#atMostLike', () => {
|
|
177
|
+
describe('with no examples', () => {
|
|
178
|
+
it('returns a JSON representation of an atMostLike matcher', () => {
|
|
179
|
+
const result = MatchersV3.atMostLike({
|
|
193
180
|
a: 'b',
|
|
194
181
|
}, 2);
|
|
195
|
-
expect(result).
|
|
182
|
+
expect(result).toEqual({
|
|
196
183
|
'pact:matcher:type': 'type',
|
|
197
184
|
max: 2,
|
|
198
185
|
value: [{ a: 'b' }],
|
|
199
186
|
});
|
|
200
187
|
});
|
|
201
188
|
});
|
|
202
|
-
describe('when provided examples',
|
|
203
|
-
it('returns a JSON representation of an atMostLike matcher with the correct number of examples',
|
|
204
|
-
|
|
189
|
+
describe('when provided examples', () => {
|
|
190
|
+
it('returns a JSON representation of an atMostLike matcher with the correct number of examples', () => {
|
|
191
|
+
const result = MatchersV3.atMostLike({
|
|
205
192
|
a: 'b',
|
|
206
193
|
}, 4, 4);
|
|
207
|
-
expect(result).
|
|
194
|
+
expect(result).toEqual({
|
|
208
195
|
'pact:matcher:type': 'type',
|
|
209
196
|
max: 4,
|
|
210
197
|
value: [{ a: 'b' }, { a: 'b' }, { a: 'b' }, { a: 'b' }],
|
|
211
198
|
});
|
|
212
199
|
});
|
|
213
200
|
});
|
|
214
|
-
it('throws an error if the number of examples is more than the maximum',
|
|
215
|
-
expect(
|
|
201
|
+
it('throws an error if the number of examples is more than the maximum', () => {
|
|
202
|
+
expect(() => MatchersV3.atMostLike({ a: 'b' }, 2, 4)).toThrow('atMostLike has a maximum of 2 but 4 elements where requested. Make sure the count is less than or equal to the max.');
|
|
216
203
|
});
|
|
217
204
|
});
|
|
218
|
-
describe('#constrainedArrayLike',
|
|
219
|
-
describe('with no examples',
|
|
220
|
-
it('returns a JSON representation of an constrainedArrayLike matcher',
|
|
221
|
-
|
|
205
|
+
describe('#constrainedArrayLike', () => {
|
|
206
|
+
describe('with no examples', () => {
|
|
207
|
+
it('returns a JSON representation of an constrainedArrayLike matcher', () => {
|
|
208
|
+
const result = MatchersV3.constrainedArrayLike({
|
|
222
209
|
a: 'b',
|
|
223
210
|
}, 2, 4);
|
|
224
|
-
expect(result).
|
|
211
|
+
expect(result).toEqual({
|
|
225
212
|
'pact:matcher:type': 'type',
|
|
226
213
|
min: 2,
|
|
227
214
|
max: 4,
|
|
@@ -229,12 +216,12 @@ describe('V3 Matchers', function () {
|
|
|
229
216
|
});
|
|
230
217
|
});
|
|
231
218
|
});
|
|
232
|
-
describe('when provided examples',
|
|
233
|
-
it('returns a JSON representation of an constrainedArrayLike matcher with the correct number of examples',
|
|
234
|
-
|
|
219
|
+
describe('when provided examples', () => {
|
|
220
|
+
it('returns a JSON representation of an constrainedArrayLike matcher with the correct number of examples', () => {
|
|
221
|
+
const result = MatchersV3.constrainedArrayLike({
|
|
235
222
|
a: 'b',
|
|
236
223
|
}, 2, 4, 3);
|
|
237
|
-
expect(result).
|
|
224
|
+
expect(result).toEqual({
|
|
238
225
|
'pact:matcher:type': 'type',
|
|
239
226
|
min: 2,
|
|
240
227
|
max: 4,
|
|
@@ -242,38 +229,34 @@ describe('V3 Matchers', function () {
|
|
|
242
229
|
});
|
|
243
230
|
});
|
|
244
231
|
});
|
|
245
|
-
it('throws an error if the number of examples is less than the minimum',
|
|
246
|
-
expect(
|
|
247
|
-
return MatchersV3.constrainedArrayLike({ a: 'b' }, 4, 6, 2);
|
|
248
|
-
}).to.throw('constrainedArrayLike has a minimum of 4 but 2 elements where requested. Make sure the count is greater than or equal to the min.');
|
|
232
|
+
it('throws an error if the number of examples is less than the minimum', () => {
|
|
233
|
+
expect(() => MatchersV3.constrainedArrayLike({ a: 'b' }, 4, 6, 2)).toThrow('constrainedArrayLike has a minimum of 4 but 2 elements where requested. Make sure the count is greater than or equal to the min.');
|
|
249
234
|
});
|
|
250
|
-
it('throws an error if the number of examples is more than the maximum',
|
|
251
|
-
expect(
|
|
252
|
-
return MatchersV3.constrainedArrayLike({ a: 'b' }, 4, 6, 8);
|
|
253
|
-
}).to.throw('constrainedArrayLike has a maximum of 6 but 8 elements where requested. Make sure the count is less than or equal to the max.');
|
|
235
|
+
it('throws an error if the number of examples is more than the maximum', () => {
|
|
236
|
+
expect(() => MatchersV3.constrainedArrayLike({ a: 'b' }, 4, 6, 8)).toThrow('constrainedArrayLike has a maximum of 6 but 8 elements where requested. Make sure the count is less than or equal to the max.');
|
|
254
237
|
});
|
|
255
238
|
});
|
|
256
|
-
describe('#integer',
|
|
257
|
-
it('returns a JSON representation of an integer matcher',
|
|
258
|
-
|
|
259
|
-
expect(result).
|
|
239
|
+
describe('#integer', () => {
|
|
240
|
+
it('returns a JSON representation of an integer matcher', () => {
|
|
241
|
+
const result = MatchersV3.integer(100);
|
|
242
|
+
expect(result).toEqual({
|
|
260
243
|
'pact:matcher:type': 'integer',
|
|
261
244
|
value: 100,
|
|
262
245
|
});
|
|
263
246
|
});
|
|
264
|
-
describe('when the example is zero',
|
|
265
|
-
it('returns a JSON representation of an integer matcher',
|
|
266
|
-
|
|
267
|
-
expect(result).
|
|
247
|
+
describe('when the example is zero', () => {
|
|
248
|
+
it('returns a JSON representation of an integer matcher', () => {
|
|
249
|
+
const result = MatchersV3.integer(0);
|
|
250
|
+
expect(result).toEqual({
|
|
268
251
|
'pact:matcher:type': 'integer',
|
|
269
252
|
value: 0,
|
|
270
253
|
});
|
|
271
254
|
});
|
|
272
255
|
});
|
|
273
|
-
describe('when no example is given',
|
|
274
|
-
it('also includes a random integer generator',
|
|
275
|
-
|
|
276
|
-
expect(result).
|
|
256
|
+
describe('when no example is given', () => {
|
|
257
|
+
it('also includes a random integer generator', () => {
|
|
258
|
+
const result = MatchersV3.integer();
|
|
259
|
+
expect(result).toEqual({
|
|
277
260
|
'pact:matcher:type': 'integer',
|
|
278
261
|
'pact:generator:type': 'RandomInt',
|
|
279
262
|
value: 101,
|
|
@@ -281,27 +264,27 @@ describe('V3 Matchers', function () {
|
|
|
281
264
|
});
|
|
282
265
|
});
|
|
283
266
|
});
|
|
284
|
-
describe('#decimal',
|
|
285
|
-
it('returns a JSON representation of an decimal matcher',
|
|
286
|
-
|
|
287
|
-
expect(result).
|
|
267
|
+
describe('#decimal', () => {
|
|
268
|
+
it('returns a JSON representation of an decimal matcher', () => {
|
|
269
|
+
const result = MatchersV3.decimal(100.3);
|
|
270
|
+
expect(result).toEqual({
|
|
288
271
|
'pact:matcher:type': 'decimal',
|
|
289
272
|
value: 100.3,
|
|
290
273
|
});
|
|
291
274
|
});
|
|
292
|
-
describe('when the example is zero',
|
|
293
|
-
it('returns a JSON representation of an integer matcher',
|
|
294
|
-
|
|
295
|
-
expect(result).
|
|
275
|
+
describe('when the example is zero', () => {
|
|
276
|
+
it('returns a JSON representation of an integer matcher', () => {
|
|
277
|
+
const result = MatchersV3.decimal(0.0);
|
|
278
|
+
expect(result).toEqual({
|
|
296
279
|
'pact:matcher:type': 'decimal',
|
|
297
280
|
value: 0.0,
|
|
298
281
|
});
|
|
299
282
|
});
|
|
300
283
|
});
|
|
301
|
-
describe('when no example is given',
|
|
302
|
-
it('also includes a random decimal generator',
|
|
303
|
-
|
|
304
|
-
expect(result).
|
|
284
|
+
describe('when no example is given', () => {
|
|
285
|
+
it('also includes a random decimal generator', () => {
|
|
286
|
+
const result = MatchersV3.decimal();
|
|
287
|
+
expect(result).toEqual({
|
|
305
288
|
'pact:matcher:type': 'decimal',
|
|
306
289
|
'pact:generator:type': 'RandomDecimal',
|
|
307
290
|
value: 12.34,
|
|
@@ -309,18 +292,18 @@ describe('V3 Matchers', function () {
|
|
|
309
292
|
});
|
|
310
293
|
});
|
|
311
294
|
});
|
|
312
|
-
describe('#number',
|
|
313
|
-
it('returns a JSON representation of an number matcher',
|
|
314
|
-
|
|
315
|
-
expect(result).
|
|
295
|
+
describe('#number', () => {
|
|
296
|
+
it('returns a JSON representation of an number matcher', () => {
|
|
297
|
+
const result = MatchersV3.number(100.3);
|
|
298
|
+
expect(result).toEqual({
|
|
316
299
|
'pact:matcher:type': 'number',
|
|
317
300
|
value: 100.3,
|
|
318
301
|
});
|
|
319
302
|
});
|
|
320
|
-
describe('when no example is given',
|
|
321
|
-
it('also includes a random integer generator',
|
|
322
|
-
|
|
323
|
-
expect(result).
|
|
303
|
+
describe('when no example is given', () => {
|
|
304
|
+
it('also includes a random integer generator', () => {
|
|
305
|
+
const result = MatchersV3.number();
|
|
306
|
+
expect(result).toEqual({
|
|
324
307
|
'pact:matcher:type': 'number',
|
|
325
308
|
'pact:generator:type': 'RandomInt',
|
|
326
309
|
value: 1234,
|
|
@@ -328,37 +311,37 @@ describe('V3 Matchers', function () {
|
|
|
328
311
|
});
|
|
329
312
|
});
|
|
330
313
|
});
|
|
331
|
-
describe('#boolean',
|
|
332
|
-
it('returns a JSON representation of a like matcher',
|
|
333
|
-
|
|
334
|
-
expect(result).
|
|
314
|
+
describe('#boolean', () => {
|
|
315
|
+
it('returns a JSON representation of a like matcher', () => {
|
|
316
|
+
const result = MatchersV3.boolean(true);
|
|
317
|
+
expect(result).toEqual({
|
|
335
318
|
'pact:matcher:type': 'type',
|
|
336
319
|
value: true,
|
|
337
320
|
});
|
|
338
321
|
});
|
|
339
322
|
});
|
|
340
|
-
describe('#string',
|
|
341
|
-
it('returns a JSON representation of a like matcher',
|
|
342
|
-
|
|
343
|
-
expect(result).
|
|
323
|
+
describe('#string', () => {
|
|
324
|
+
it('returns a JSON representation of a like matcher', () => {
|
|
325
|
+
const result = MatchersV3.string('true');
|
|
326
|
+
expect(result).toEqual({
|
|
344
327
|
'pact:matcher:type': 'type',
|
|
345
328
|
value: 'true',
|
|
346
329
|
});
|
|
347
330
|
});
|
|
348
331
|
});
|
|
349
|
-
describe('#regex',
|
|
350
|
-
it('returns a JSON representation of a regex matcher',
|
|
351
|
-
|
|
352
|
-
expect(result).
|
|
332
|
+
describe('#regex', () => {
|
|
333
|
+
it('returns a JSON representation of a regex matcher', () => {
|
|
334
|
+
const result = MatchersV3.regex('\\d+', '1234');
|
|
335
|
+
expect(result).toEqual({
|
|
353
336
|
'pact:matcher:type': 'regex',
|
|
354
337
|
regex: '\\d+',
|
|
355
338
|
value: '1234',
|
|
356
339
|
});
|
|
357
340
|
});
|
|
358
|
-
describe('when given a regular expression',
|
|
359
|
-
it('returns a JSON representation of a regex matcher',
|
|
360
|
-
|
|
361
|
-
expect(result).
|
|
341
|
+
describe('when given a regular expression', () => {
|
|
342
|
+
it('returns a JSON representation of a regex matcher', () => {
|
|
343
|
+
const result = MatchersV3.regex(/\d+/, '1234');
|
|
344
|
+
expect(result).toEqual({
|
|
362
345
|
'pact:matcher:type': 'regex',
|
|
363
346
|
regex: '\\d+',
|
|
364
347
|
value: '1234',
|
|
@@ -366,139 +349,137 @@ describe('V3 Matchers', function () {
|
|
|
366
349
|
});
|
|
367
350
|
});
|
|
368
351
|
});
|
|
369
|
-
describe('#equal',
|
|
370
|
-
it('returns a JSON representation of an equality matcher',
|
|
371
|
-
|
|
372
|
-
expect(result).
|
|
352
|
+
describe('#equal', () => {
|
|
353
|
+
it('returns a JSON representation of an equality matcher', () => {
|
|
354
|
+
const result = MatchersV3.equal('true');
|
|
355
|
+
expect(result).toEqual({
|
|
373
356
|
'pact:matcher:type': 'equality',
|
|
374
357
|
value: 'true',
|
|
375
358
|
});
|
|
376
359
|
});
|
|
377
360
|
});
|
|
378
|
-
describe('#datetime',
|
|
379
|
-
describe('when an example is given',
|
|
380
|
-
it('returns a JSON representation of a datetime matcher',
|
|
381
|
-
|
|
382
|
-
expect(result).
|
|
361
|
+
describe('#datetime', () => {
|
|
362
|
+
describe('when an example is given', () => {
|
|
363
|
+
it('returns a JSON representation of a datetime matcher', () => {
|
|
364
|
+
const result = MatchersV3.datetime("yyyy-MM-dd'T'HH:mm:ss.SSSX", '2016-02-11T09:46:56.023Z');
|
|
365
|
+
expect(result).toEqual({
|
|
383
366
|
'pact:matcher:type': 'timestamp',
|
|
384
367
|
format: "yyyy-MM-dd'T'HH:mm:ss.SSSX",
|
|
385
368
|
value: '2016-02-11T09:46:56.023Z',
|
|
386
369
|
});
|
|
387
370
|
});
|
|
388
371
|
});
|
|
389
|
-
describe('when example is an empty string',
|
|
390
|
-
it('throws an error',
|
|
391
|
-
expect(
|
|
392
|
-
return MatchersV3.datetime("yyyy-MM-dd'T'HH:mm:ss.SSSX", '');
|
|
393
|
-
}).to.throw('you must provide an example datetime');
|
|
372
|
+
describe('when example is an empty string', () => {
|
|
373
|
+
it('throws an error', () => {
|
|
374
|
+
expect(() => MatchersV3.datetime("yyyy-MM-dd'T'HH:mm:ss.SSSX", '')).toThrow('you must provide an example datetime');
|
|
394
375
|
});
|
|
395
376
|
});
|
|
396
377
|
});
|
|
397
|
-
describe('#time',
|
|
398
|
-
describe('when an example is given',
|
|
399
|
-
it('returns a JSON representation of a time matcher',
|
|
400
|
-
|
|
401
|
-
expect(result).
|
|
378
|
+
describe('#time', () => {
|
|
379
|
+
describe('when an example is given', () => {
|
|
380
|
+
it('returns a JSON representation of a time matcher', () => {
|
|
381
|
+
const result = MatchersV3.time('HH:mm:ss', '09:46:56');
|
|
382
|
+
expect(result).toEqual({
|
|
402
383
|
'pact:matcher:type': 'time',
|
|
403
384
|
format: 'HH:mm:ss',
|
|
404
385
|
value: '09:46:56',
|
|
405
386
|
});
|
|
406
387
|
});
|
|
407
388
|
});
|
|
408
|
-
describe('when example is an empty string',
|
|
409
|
-
it('throws an error',
|
|
410
|
-
expect(
|
|
389
|
+
describe('when example is an empty string', () => {
|
|
390
|
+
it('throws an error', () => {
|
|
391
|
+
expect(() => MatchersV3.time('HH:mm:ss', '')).toThrow('you must provide an example time');
|
|
411
392
|
});
|
|
412
393
|
});
|
|
413
394
|
});
|
|
414
|
-
describe('#date',
|
|
415
|
-
describe('when an example is given',
|
|
416
|
-
it('returns a JSON representation of a date matcher',
|
|
417
|
-
|
|
418
|
-
expect(result).
|
|
395
|
+
describe('#date', () => {
|
|
396
|
+
describe('when an example is given', () => {
|
|
397
|
+
it('returns a JSON representation of a date matcher', () => {
|
|
398
|
+
const result = MatchersV3.date('yyyy-MM-dd', '2016-02-11');
|
|
399
|
+
expect(result).toEqual({
|
|
419
400
|
'pact:matcher:type': 'date',
|
|
420
401
|
format: 'yyyy-MM-dd',
|
|
421
402
|
value: '2016-02-11',
|
|
422
403
|
});
|
|
423
404
|
});
|
|
424
405
|
});
|
|
425
|
-
describe('when example is an empty string',
|
|
426
|
-
it('throws an error',
|
|
427
|
-
expect(
|
|
406
|
+
describe('when example is an empty string', () => {
|
|
407
|
+
it('throws an error', () => {
|
|
408
|
+
expect(() => MatchersV3.date('yyyy-MM-dd', '')).toThrow('you must provide an example date');
|
|
428
409
|
});
|
|
429
410
|
});
|
|
430
411
|
});
|
|
431
|
-
describe('#includes',
|
|
432
|
-
it('returns a JSON representation of an include matcher',
|
|
433
|
-
|
|
434
|
-
expect(result).
|
|
412
|
+
describe('#includes', () => {
|
|
413
|
+
it('returns a JSON representation of an include matcher', () => {
|
|
414
|
+
const result = MatchersV3.includes('true');
|
|
415
|
+
expect(result).toEqual({
|
|
435
416
|
'pact:matcher:type': 'include',
|
|
436
417
|
value: 'true',
|
|
437
418
|
});
|
|
438
419
|
});
|
|
439
420
|
});
|
|
440
|
-
describe('#nullValue',
|
|
441
|
-
it('returns a JSON representation of an null matcher',
|
|
442
|
-
|
|
443
|
-
expect(result).
|
|
421
|
+
describe('#nullValue', () => {
|
|
422
|
+
it('returns a JSON representation of an null matcher', () => {
|
|
423
|
+
const result = MatchersV3.nullValue();
|
|
424
|
+
expect(result).toEqual({
|
|
444
425
|
'pact:matcher:type': 'null',
|
|
445
426
|
value: null,
|
|
446
427
|
});
|
|
447
428
|
});
|
|
448
429
|
});
|
|
449
|
-
describe('#url',
|
|
450
|
-
it('returns a JSON representation of a regex matcher for the URL',
|
|
451
|
-
|
|
430
|
+
describe('#url', () => {
|
|
431
|
+
it('returns a JSON representation of a regex matcher for the URL', () => {
|
|
432
|
+
const result = MatchersV3.url2('http://localhost:8080', [
|
|
452
433
|
'users',
|
|
453
434
|
'1234',
|
|
454
435
|
'posts',
|
|
455
436
|
'latest',
|
|
456
437
|
]);
|
|
457
|
-
expect(result).
|
|
438
|
+
expect(result).toEqual({
|
|
458
439
|
'pact:matcher:type': 'regex',
|
|
459
440
|
regex: '.*(\\/users\\/1234\\/posts\\/latest)$',
|
|
460
441
|
value: 'http://localhost:8080/users/1234/posts/latest',
|
|
461
442
|
});
|
|
462
443
|
});
|
|
463
|
-
describe('when provided with a regex matcher',
|
|
464
|
-
it('returns a JSON representation of a regex matcher for the URL',
|
|
465
|
-
|
|
444
|
+
describe('when provided with a regex matcher', () => {
|
|
445
|
+
it('returns a JSON representation of a regex matcher for the URL', () => {
|
|
446
|
+
const result = MatchersV3.url2('http://localhost:8080', [
|
|
466
447
|
'users',
|
|
467
448
|
MatchersV3.regex('\\d+', '1234'),
|
|
468
449
|
'posts',
|
|
469
450
|
'latest',
|
|
470
451
|
]);
|
|
471
|
-
expect(result).
|
|
452
|
+
expect(result).toEqual({
|
|
472
453
|
'pact:matcher:type': 'regex',
|
|
473
454
|
regex: '.*(\\/users\\/\\d+\\/posts\\/latest)$',
|
|
474
455
|
value: 'http://localhost:8080/users/1234/posts/latest',
|
|
475
456
|
});
|
|
476
457
|
});
|
|
477
458
|
});
|
|
478
|
-
describe('when provided with a regular expression',
|
|
479
|
-
it('returns a JSON representation of a regex matcher for the URL',
|
|
480
|
-
|
|
459
|
+
describe('when provided with a regular expression', () => {
|
|
460
|
+
it('returns a JSON representation of a regex matcher for the URL', () => {
|
|
461
|
+
const result = MatchersV3.url2('http://localhost:8080', [
|
|
481
462
|
'users',
|
|
482
463
|
/\d+/,
|
|
483
464
|
'posts',
|
|
484
465
|
'latest',
|
|
485
466
|
]);
|
|
486
|
-
expect(result).
|
|
467
|
+
expect(result).toMatchObject({
|
|
487
468
|
'pact:matcher:type': 'regex',
|
|
488
469
|
regex: '.*(\\/users\\/\\d+\\/posts\\/latest)$',
|
|
489
470
|
});
|
|
490
|
-
expect(result.value).
|
|
471
|
+
expect(result.value).toMatch(/\/users\/\d+\/posts\/latest$/);
|
|
491
472
|
});
|
|
492
473
|
});
|
|
493
|
-
describe('when no base URL is provided',
|
|
494
|
-
it('returns regex matcher and a MockServerURL generator',
|
|
495
|
-
|
|
474
|
+
describe('when no base URL is provided', () => {
|
|
475
|
+
it('returns regex matcher and a MockServerURL generator', () => {
|
|
476
|
+
const result = MatchersV3.url([
|
|
496
477
|
'users',
|
|
497
478
|
MatchersV3.regex('\\d+', '1234'),
|
|
498
479
|
'posts',
|
|
499
480
|
'latest',
|
|
500
481
|
]);
|
|
501
|
-
expect(result).
|
|
482
|
+
expect(result).toEqual({
|
|
502
483
|
'pact:matcher:type': 'regex',
|
|
503
484
|
'pact:generator:type': 'MockServerURL',
|
|
504
485
|
regex: '.*(\\/users\\/\\d+\\/posts\\/latest)$',
|
|
@@ -508,25 +489,23 @@ describe('V3 Matchers', function () {
|
|
|
508
489
|
});
|
|
509
490
|
});
|
|
510
491
|
});
|
|
511
|
-
describe('#uuid',
|
|
512
|
-
it('returns a JSON representation of an regex matcher for UUIDs',
|
|
513
|
-
|
|
514
|
-
expect(result).
|
|
492
|
+
describe('#uuid', () => {
|
|
493
|
+
it('returns a JSON representation of an regex matcher for UUIDs', () => {
|
|
494
|
+
const result = MatchersV3.uuid('ba4bd1bc-5556-11eb-9286-d71bc5b507be');
|
|
495
|
+
expect(result).toEqual({
|
|
515
496
|
'pact:matcher:type': 'regex',
|
|
516
497
|
regex: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
|
|
517
498
|
value: 'ba4bd1bc-5556-11eb-9286-d71bc5b507be',
|
|
518
499
|
});
|
|
519
500
|
});
|
|
520
|
-
it('throws an exception if the example value does not match the UUID regex',
|
|
521
|
-
expect(
|
|
522
|
-
expect(
|
|
523
|
-
expect(
|
|
524
|
-
return MatchersV3.uuid('ba4bd1bc-5556-11eb-9286-d71bc5b507be-1234');
|
|
525
|
-
}).to.throw();
|
|
501
|
+
it('throws an exception if the example value does not match the UUID regex', () => {
|
|
502
|
+
expect(() => MatchersV3.uuid('not a uuid')).toThrow();
|
|
503
|
+
expect(() => MatchersV3.uuid('ba4bd1bc-5556-11eb-9286')).toThrow();
|
|
504
|
+
expect(() => MatchersV3.uuid('ba4bd1bc-5556-11eb-9286-d71bc5b507be-1234')).toThrow();
|
|
526
505
|
});
|
|
527
|
-
it('if no example is provided, it sets up a generator',
|
|
528
|
-
|
|
529
|
-
expect(result).
|
|
506
|
+
it('if no example is provided, it sets up a generator', () => {
|
|
507
|
+
const result = MatchersV3.uuid();
|
|
508
|
+
expect(result).toEqual({
|
|
530
509
|
'pact:matcher:type': 'regex',
|
|
531
510
|
'pact:generator:type': 'Uuid',
|
|
532
511
|
regex: '[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}',
|
|
@@ -534,10 +513,10 @@ describe('V3 Matchers', function () {
|
|
|
534
513
|
});
|
|
535
514
|
});
|
|
536
515
|
});
|
|
537
|
-
describe('#reify',
|
|
538
|
-
describe('when given an object with no matchers',
|
|
539
|
-
|
|
540
|
-
value: 'data',
|
|
516
|
+
describe('#reify', () => {
|
|
517
|
+
describe('when given an object with no matchers', () => {
|
|
518
|
+
const object = {
|
|
519
|
+
value: 'data',
|
|
541
520
|
more: 'strings',
|
|
542
521
|
an: ['array'],
|
|
543
522
|
someObject: {
|
|
@@ -545,12 +524,12 @@ describe('V3 Matchers', function () {
|
|
|
545
524
|
withNumber: 1,
|
|
546
525
|
},
|
|
547
526
|
};
|
|
548
|
-
it('returns just that object',
|
|
549
|
-
expect(MatchersV3.reify(object)).
|
|
527
|
+
it('returns just that object', () => {
|
|
528
|
+
expect(MatchersV3.reify(object)).toEqual(object);
|
|
550
529
|
});
|
|
551
530
|
});
|
|
552
|
-
describe('when given an object with null values',
|
|
553
|
-
|
|
531
|
+
describe('when given an object with null values', () => {
|
|
532
|
+
const object = {
|
|
554
533
|
some: 'data',
|
|
555
534
|
more: null,
|
|
556
535
|
an: [null],
|
|
@@ -560,12 +539,12 @@ describe('V3 Matchers', function () {
|
|
|
560
539
|
andNull: null,
|
|
561
540
|
},
|
|
562
541
|
};
|
|
563
|
-
it('returns just that object',
|
|
564
|
-
expect(MatchersV3.reify(object)).
|
|
542
|
+
it('returns just that object', () => {
|
|
543
|
+
expect(MatchersV3.reify(object)).toEqual(object);
|
|
565
544
|
});
|
|
566
545
|
});
|
|
567
|
-
describe('when given an object with some matchers',
|
|
568
|
-
|
|
546
|
+
describe('when given an object with some matchers', () => {
|
|
547
|
+
const someMatchers = {
|
|
569
548
|
some: MatchersV3.like('data'),
|
|
570
549
|
more: 'strings',
|
|
571
550
|
an: ['array'],
|
|
@@ -578,7 +557,7 @@ describe('V3 Matchers', function () {
|
|
|
578
557
|
withAnotherNumber: MatchersV3.like(2),
|
|
579
558
|
},
|
|
580
559
|
};
|
|
581
|
-
|
|
560
|
+
const expected = {
|
|
582
561
|
some: 'data',
|
|
583
562
|
more: 'strings',
|
|
584
563
|
an: ['array'],
|
|
@@ -591,21 +570,21 @@ describe('V3 Matchers', function () {
|
|
|
591
570
|
withAnotherNumber: 2,
|
|
592
571
|
},
|
|
593
572
|
};
|
|
594
|
-
it('returns without matching guff',
|
|
595
|
-
expect(MatchersV3.reify(someMatchers)).
|
|
573
|
+
it('returns without matching guff', () => {
|
|
574
|
+
expect(MatchersV3.reify(someMatchers)).toEqual(expected);
|
|
596
575
|
});
|
|
597
576
|
});
|
|
598
|
-
describe('when given a simple matcher',
|
|
599
|
-
it('removes all matching guff',
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
expect(MatchersV3.isMatcher(matcher)).
|
|
603
|
-
expect(MatchersV3.reify(matcher)).
|
|
577
|
+
describe('when given a simple matcher', () => {
|
|
578
|
+
it('removes all matching guff', () => {
|
|
579
|
+
const expected = 'myawesomeword';
|
|
580
|
+
const matcher = MatchersV3.regex('\\w+', 'myawesomeword');
|
|
581
|
+
expect(MatchersV3.isMatcher(matcher)).toBe(true);
|
|
582
|
+
expect(MatchersV3.reify(matcher)).toEqual(expected);
|
|
604
583
|
});
|
|
605
584
|
});
|
|
606
|
-
describe('when given a complex nested object with matchers',
|
|
607
|
-
it('removes all matching guff',
|
|
608
|
-
|
|
585
|
+
describe('when given a complex nested object with matchers', () => {
|
|
586
|
+
it('removes all matching guff', () => {
|
|
587
|
+
const o = MatchersV3.like({
|
|
609
588
|
stringMatcher: {
|
|
610
589
|
awesomeSetting: MatchersV3.like('a string'),
|
|
611
590
|
},
|
|
@@ -625,7 +604,7 @@ describe('V3 Matchers', function () {
|
|
|
625
604
|
}, 3),
|
|
626
605
|
},
|
|
627
606
|
});
|
|
628
|
-
|
|
607
|
+
const expected = {
|
|
629
608
|
stringMatcher: {
|
|
630
609
|
awesomeSetting: 'a string',
|
|
631
610
|
},
|
|
@@ -655,22 +634,92 @@ describe('V3 Matchers', function () {
|
|
|
655
634
|
],
|
|
656
635
|
},
|
|
657
636
|
};
|
|
658
|
-
expect(MatchersV3.reify(o)).
|
|
637
|
+
expect(MatchersV3.reify(o)).toEqual(expected);
|
|
659
638
|
});
|
|
660
639
|
});
|
|
661
|
-
describe('when given a matcher and field named "value"',
|
|
662
|
-
it('should not be isMatcher"',
|
|
663
|
-
|
|
640
|
+
describe('when given a matcher and field named "value"', () => {
|
|
641
|
+
it('should not be isMatcher"', () => {
|
|
642
|
+
const resultMatcher = MatchersV3.like({
|
|
664
643
|
a: 'b',
|
|
665
644
|
c: MatchersV3.atLeastOneLike({ value: '1', a: 'b', aa: 'bb' }),
|
|
666
645
|
});
|
|
667
|
-
|
|
668
|
-
expect(result).
|
|
646
|
+
const result = MatchersV3.reify(resultMatcher);
|
|
647
|
+
expect(result).toEqual({
|
|
669
648
|
a: 'b',
|
|
670
649
|
c: [{ value: '1', a: 'b', aa: 'bb' }],
|
|
671
650
|
});
|
|
672
651
|
});
|
|
673
652
|
});
|
|
674
653
|
});
|
|
654
|
+
describe('matchStatus', () => {
|
|
655
|
+
it('creates a StatusCodeMatcher for an HTTPResponseStatusClass', () => {
|
|
656
|
+
const matcher = MatchersV3.matchStatus(200, MatchersV3.HTTPResponseStatusClass.Success);
|
|
657
|
+
expect(matcher).toEqual({
|
|
658
|
+
'pact:matcher:type': 'statusCode',
|
|
659
|
+
status: 'success',
|
|
660
|
+
value: 200,
|
|
661
|
+
});
|
|
662
|
+
});
|
|
663
|
+
it('creates a StatusCodeMatcher for a list of status codes', () => {
|
|
664
|
+
const matcher = MatchersV3.matchStatus(200, [200, 201]);
|
|
665
|
+
expect(matcher).toEqual({
|
|
666
|
+
'pact:matcher:type': 'statusCode',
|
|
667
|
+
status: [200, 201],
|
|
668
|
+
value: 200,
|
|
669
|
+
});
|
|
670
|
+
});
|
|
671
|
+
it('creates a StatusCodeMatcher for ClientError class', () => {
|
|
672
|
+
const matcher = MatchersV3.matchStatus(400, MatchersV3.HTTPResponseStatusClass.ClientError);
|
|
673
|
+
expect(matcher).toEqual({
|
|
674
|
+
'pact:matcher:type': 'statusCode',
|
|
675
|
+
status: 'clientError',
|
|
676
|
+
value: 400,
|
|
677
|
+
});
|
|
678
|
+
});
|
|
679
|
+
it('creates a StatusCodeMatcher for ServerError class', () => {
|
|
680
|
+
const matcher = MatchersV3.matchStatus(500, MatchersV3.HTTPResponseStatusClass.ServerError);
|
|
681
|
+
expect(matcher).toEqual({
|
|
682
|
+
'pact:matcher:type': 'statusCode',
|
|
683
|
+
status: 'serverError',
|
|
684
|
+
value: 500,
|
|
685
|
+
});
|
|
686
|
+
});
|
|
687
|
+
it('creates a StatusCodeMatcher for Redirect class', () => {
|
|
688
|
+
const matcher = MatchersV3.matchStatus(301, MatchersV3.HTTPResponseStatusClass.Redirect);
|
|
689
|
+
expect(matcher).toEqual({
|
|
690
|
+
'pact:matcher:type': 'statusCode',
|
|
691
|
+
status: 'redirect',
|
|
692
|
+
value: 301,
|
|
693
|
+
});
|
|
694
|
+
});
|
|
695
|
+
it('creates a StatusCodeMatcher for Information class', () => {
|
|
696
|
+
const matcher = MatchersV3.matchStatus(100, MatchersV3.HTTPResponseStatusClass.Information);
|
|
697
|
+
expect(matcher).toEqual({
|
|
698
|
+
'pact:matcher:type': 'statusCode',
|
|
699
|
+
status: 'information',
|
|
700
|
+
value: 100,
|
|
701
|
+
});
|
|
702
|
+
});
|
|
703
|
+
it('creates a StatusCodeMatcher for NonError class', () => {
|
|
704
|
+
const matcher = MatchersV3.matchStatus(200, MatchersV3.HTTPResponseStatusClass.NonError);
|
|
705
|
+
expect(matcher).toEqual({
|
|
706
|
+
'pact:matcher:type': 'statusCode',
|
|
707
|
+
status: 'nonError',
|
|
708
|
+
value: 200,
|
|
709
|
+
});
|
|
710
|
+
});
|
|
711
|
+
it('creates a StatusCodeMatcher for Error class', () => {
|
|
712
|
+
const matcher = MatchersV3.matchStatus(400, MatchersV3.HTTPResponseStatusClass.Error);
|
|
713
|
+
expect(matcher).toEqual({
|
|
714
|
+
'pact:matcher:type': 'statusCode',
|
|
715
|
+
status: 'error',
|
|
716
|
+
value: 400,
|
|
717
|
+
});
|
|
718
|
+
});
|
|
719
|
+
it('reify returns the example value from a StatusCodeMatcher', () => {
|
|
720
|
+
const matcher = MatchersV3.matchStatus(201, MatchersV3.HTTPResponseStatusClass.Success);
|
|
721
|
+
expect(MatchersV3.reify(matcher)).toEqual(201);
|
|
722
|
+
});
|
|
723
|
+
});
|
|
675
724
|
});
|
|
676
725
|
//# sourceMappingURL=matchers.spec.js.map
|