@pact-foundation/pact 16.3.0 → 16.4.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 +16 -3
- package/CONTRIBUTING.md +2 -2
- package/README.md +6 -2
- package/package.json +25 -28
- 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 +1 -1
- package/src/common/matchingRules.js +21 -21
- 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 +41 -53
- 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 +26 -26
- 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 -18
- 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 +81 -66
- 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 +77 -70
- package/src/dsl/interaction.spec.js.map +1 -1
- package/src/dsl/matchers.d.ts +1 -1
- package/src/dsl/matchers.js +19 -31
- package/src/dsl/matchers.js.map +1 -1
- package/src/dsl/matchers.spec.js +199 -208
- 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 +84 -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 +2 -2
- package/src/dsl/verifier/proxy/parseBody.js.map +1 -1
- package/src/dsl/verifier/proxy/parseBody.spec.js +31 -76
- 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 +14 -14
- 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 +49 -64
- 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 -159
- 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 -85
- 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 +1 -1
- package/src/dsl/verifier/verifier.js +49 -56
- package/src/dsl/verifier/verifier.js.map +1 -1
- package/src/dsl/verifier/verifier.spec.js +76 -93
- 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 +30 -31
- 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 +75 -125
- 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.js +1 -1
- package/src/index.js.map +1 -1
- package/src/messageConsumerPact.d.ts +3 -3
- package/src/messageConsumerPact.js +50 -51
- package/src/messageConsumerPact.js.map +1 -1
- package/src/messageConsumerPact.spec.js +50 -49
- 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 +75 -66
- package/src/messageProviderPact.spec.js.map +1 -1
- package/src/pact.integration.spec.js +250 -268
- 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.d.ts +2 -2
- package/src/v3/ffi.js +18 -16
- package/src/v3/ffi.js.map +1 -1
- package/src/v3/ffi.spec.d.ts +1 -0
- package/src/v3/ffi.spec.js +50 -0
- package/src/v3/ffi.spec.js.map +1 -0
- 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/matchers.d.ts +2 -2
- package/src/v3/matchers.js +112 -147
- package/src/v3/matchers.js.map +1 -1
- package/src/v3/matchers.spec.js +168 -187
- package/src/v3/matchers.spec.js.map +1 -1
- package/src/v3/pact.d.ts +2 -2
- package/src/v3/pact.js +103 -151
- package/src/v3/pact.js.map +1 -1
- package/src/v3/types.d.ts +1 -1
- package/src/v3/xml/xmlBuilder.d.ts +1 -3
- package/src/v3/xml/xmlBuilder.js +7 -9
- package/src/v3/xml/xmlBuilder.js.map +1 -1
- package/src/v3/xml/xmlElement.d.ts +2 -2
- package/src/v3/xml/xmlElement.js +24 -41
- package/src/v3/xml/xmlElement.js.map +1 -1
- package/src/v3/xml/xmlElement.spec.js +23 -25
- package/src/v3/xml/xmlElement.spec.js.map +1 -1
- package/src/v3/xml/xmlNode.js +2 -5
- package/src/v3/xml/xmlNode.js.map +1 -1
- package/src/v3/xml/xmlText.d.ts +1 -1
- package/src/v3/xml/xmlText.js +9 -25
- package/src/v3/xml/xmlText.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 +48 -93
- package/src/v4/http/index.js.map +1 -1
- 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 +2 -2
- package/src/v4/http/interactionWithPluginRequest.js +11 -8
- 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 +2 -2
- package/src/v4/http/interactionWithRequest.js +11 -8
- package/src/v4/http/interactionWithRequest.js.map +1 -1
- 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 +3 -3
- package/src/v4/http/requestBuilder.js +32 -34
- package/src/v4/http/requestBuilder.js.map +1 -1
- package/src/v4/http/requestWithPluginBuilder.d.ts +2 -2
- package/src/v4/http/requestWithPluginBuilder.js +26 -46
- package/src/v4/http/requestWithPluginBuilder.js.map +1 -1
- package/src/v4/http/responseBuilder.d.ts +3 -3
- package/src/v4/http/responseBuilder.js +24 -25
- package/src/v4/http/responseBuilder.js.map +1 -1
- 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/types.d.ts +3 -2
- 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 +4 -4
- package/src/v4/index.js +31 -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/dsl/matchers.spec.js
CHANGED
|
@@ -1,33 +1,22 @@
|
|
|
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
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
describe('Matcher',
|
|
17
|
-
describe('can compile the types',
|
|
18
|
-
describe('with interfaces',
|
|
19
|
-
it('compiles with nested examples from issue 1054',
|
|
20
|
-
|
|
3
|
+
const chai_1 = require("chai");
|
|
4
|
+
const matchers_1 = require("./matchers");
|
|
5
|
+
describe('Matcher', () => {
|
|
6
|
+
describe('can compile the types', () => {
|
|
7
|
+
describe('with interfaces', () => {
|
|
8
|
+
it('compiles with nested examples from issue 1054', () => {
|
|
9
|
+
const f = { a: 'working example' };
|
|
21
10
|
(0, matchers_1.like)(f);
|
|
22
|
-
(0, matchers_1.like)(
|
|
11
|
+
(0, matchers_1.like)({ ...f });
|
|
23
12
|
(0, matchers_1.like)(Object.freeze(f));
|
|
24
|
-
|
|
13
|
+
const r = { id: 'some guid', foo: { a: 'example' } };
|
|
25
14
|
(0, matchers_1.like)(r);
|
|
26
|
-
(0, matchers_1.like)(
|
|
15
|
+
(0, matchers_1.like)({ ...r });
|
|
27
16
|
(0, matchers_1.like)(Object.freeze(f));
|
|
28
17
|
});
|
|
29
|
-
it('compiles when InterfaceToTemplate is used',
|
|
30
|
-
|
|
18
|
+
it('compiles when InterfaceToTemplate is used', () => {
|
|
19
|
+
const template = {
|
|
31
20
|
someArray: ['one', 'two'],
|
|
32
21
|
someNumber: 1,
|
|
33
22
|
someString: "it's a string",
|
|
@@ -36,12 +25,12 @@ describe('Matcher', function () {
|
|
|
36
25
|
bar: 'some other string',
|
|
37
26
|
},
|
|
38
27
|
};
|
|
39
|
-
|
|
28
|
+
const _unused = (0, matchers_1.like)(template);
|
|
40
29
|
});
|
|
41
30
|
});
|
|
42
|
-
describe('with types',
|
|
43
|
-
it('compiles',
|
|
44
|
-
|
|
31
|
+
describe('with types', () => {
|
|
32
|
+
it('compiles', () => {
|
|
33
|
+
const template = {
|
|
45
34
|
someArray: ['one', 'two'],
|
|
46
35
|
someNumber: 1,
|
|
47
36
|
someString: "it's a string",
|
|
@@ -50,11 +39,11 @@ describe('Matcher', function () {
|
|
|
50
39
|
bar: 'some other string',
|
|
51
40
|
},
|
|
52
41
|
};
|
|
53
|
-
|
|
42
|
+
const _unused = (0, matchers_1.like)(template);
|
|
54
43
|
});
|
|
55
44
|
});
|
|
56
|
-
it('compiles nested likes',
|
|
57
|
-
|
|
45
|
+
it('compiles nested likes', () => {
|
|
46
|
+
const _unused = (0, matchers_1.like)({
|
|
58
47
|
someArray: ['one', 'two'],
|
|
59
48
|
someNumber: (0, matchers_1.like)(1),
|
|
60
49
|
someString: "it's a string",
|
|
@@ -65,53 +54,54 @@ describe('Matcher', function () {
|
|
|
65
54
|
});
|
|
66
55
|
});
|
|
67
56
|
});
|
|
68
|
-
describe('#validateExample',
|
|
69
|
-
describe('when given a valid regex',
|
|
70
|
-
describe('and a matching example',
|
|
71
|
-
it('returns true',
|
|
57
|
+
describe('#validateExample', () => {
|
|
58
|
+
describe('when given a valid regex', () => {
|
|
59
|
+
describe('and a matching example', () => {
|
|
60
|
+
it('returns true', () => {
|
|
72
61
|
(0, chai_1.expect)((0, matchers_1.validateExample)('2010-01-01', matchers_1.ISO8601_DATE_FORMAT)).to.eql(true);
|
|
73
62
|
});
|
|
74
63
|
});
|
|
75
|
-
describe('and a failing example',
|
|
76
|
-
it('returns false',
|
|
64
|
+
describe('and a failing example', () => {
|
|
65
|
+
it('returns false', () => {
|
|
77
66
|
(0, chai_1.expect)((0, matchers_1.validateExample)('not a date', matchers_1.ISO8601_DATE_FORMAT)).to.eql(false);
|
|
78
67
|
});
|
|
79
68
|
});
|
|
80
69
|
});
|
|
81
|
-
describe('when given an invalid regex',
|
|
82
|
-
it('returns an error',
|
|
83
|
-
(0, chai_1.expect)(
|
|
70
|
+
describe('when given an invalid regex', () => {
|
|
71
|
+
it('returns an error', () => {
|
|
72
|
+
(0, chai_1.expect)(() => {
|
|
84
73
|
(0, matchers_1.validateExample)('', 'abc(');
|
|
85
74
|
}).to.throw(Error);
|
|
86
75
|
});
|
|
87
76
|
});
|
|
88
77
|
});
|
|
89
|
-
describe('#term',
|
|
90
|
-
describe('when given a valid regular expression and example',
|
|
91
|
-
it('returns a serialized Ruby object',
|
|
92
|
-
|
|
78
|
+
describe('#term', () => {
|
|
79
|
+
describe('when given a valid regular expression and example', () => {
|
|
80
|
+
it('returns a serialized Ruby object', () => {
|
|
81
|
+
const expected = {
|
|
93
82
|
value: 'myawesomeword',
|
|
94
83
|
regex: '\\w+',
|
|
95
84
|
'pact:matcher:type': 'regex',
|
|
96
85
|
};
|
|
97
|
-
|
|
86
|
+
const match = (0, matchers_1.term)({
|
|
98
87
|
generate: 'myawesomeword',
|
|
99
88
|
matcher: '\\w+',
|
|
100
89
|
});
|
|
101
90
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
102
91
|
});
|
|
103
92
|
});
|
|
104
|
-
describe('when not provided with a valid expression',
|
|
105
|
-
|
|
93
|
+
describe('when not provided with a valid expression', () => {
|
|
94
|
+
// biome-ignore lint/suspicious/noExplicitAny: intentionally passing invalid argument types to test error handling
|
|
95
|
+
const createTheTerm = (badArg) => () => {
|
|
106
96
|
(0, matchers_1.term)(badArg);
|
|
107
|
-
};
|
|
108
|
-
describe('when no term is provided',
|
|
109
|
-
it('throws an Error',
|
|
110
|
-
(0, chai_1.expect)(createTheTerm.call({})).to.throw(Error);
|
|
97
|
+
};
|
|
98
|
+
describe('when no term is provided', () => {
|
|
99
|
+
it('throws an Error', () => {
|
|
100
|
+
(0, chai_1.expect)(createTheTerm.call({}, undefined)).to.throw(Error);
|
|
111
101
|
});
|
|
112
102
|
});
|
|
113
|
-
describe('when an invalid term is provided',
|
|
114
|
-
it('throws an Error',
|
|
103
|
+
describe('when an invalid term is provided', () => {
|
|
104
|
+
it('throws an Error', () => {
|
|
115
105
|
(0, chai_1.expect)(createTheTerm({})).to.throw(Error);
|
|
116
106
|
(0, chai_1.expect)(createTheTerm('')).to.throw(Error);
|
|
117
107
|
(0, chai_1.expect)(createTheTerm({ value: 'foo' })).to.throw(Error);
|
|
@@ -119,9 +109,9 @@ describe('Matcher', function () {
|
|
|
119
109
|
});
|
|
120
110
|
});
|
|
121
111
|
});
|
|
122
|
-
describe("when given an example that doesn't match the regular expression",
|
|
123
|
-
it('fails with an error',
|
|
124
|
-
(0, chai_1.expect)(
|
|
112
|
+
describe("when given an example that doesn't match the regular expression", () => {
|
|
113
|
+
it('fails with an error', () => {
|
|
114
|
+
(0, chai_1.expect)(() => {
|
|
125
115
|
(0, matchers_1.term)({
|
|
126
116
|
generate: 'abc',
|
|
127
117
|
matcher: matchers_1.ISO8601_DATE_FORMAT,
|
|
@@ -130,90 +120,91 @@ describe('Matcher', function () {
|
|
|
130
120
|
});
|
|
131
121
|
});
|
|
132
122
|
});
|
|
133
|
-
describe('#somethingLike',
|
|
134
|
-
describe('when provided a value',
|
|
135
|
-
it('returns a serialized Ruby object',
|
|
136
|
-
|
|
123
|
+
describe('#somethingLike', () => {
|
|
124
|
+
describe('when provided a value', () => {
|
|
125
|
+
it('returns a serialized Ruby object', () => {
|
|
126
|
+
const expected = {
|
|
137
127
|
value: 'myspecialvalue',
|
|
138
128
|
'pact:matcher:type': 'type',
|
|
139
129
|
};
|
|
140
|
-
|
|
130
|
+
const match = (0, matchers_1.somethingLike)('myspecialvalue');
|
|
141
131
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
142
132
|
});
|
|
143
133
|
});
|
|
144
|
-
describe('when not provided with a valid value',
|
|
145
|
-
|
|
134
|
+
describe('when not provided with a valid value', () => {
|
|
135
|
+
// biome-ignore lint/suspicious/noExplicitAny: intentionally passing invalid argument types to test error handling
|
|
136
|
+
const createTheValue = (badArg) => () => {
|
|
146
137
|
(0, matchers_1.somethingLike)(badArg);
|
|
147
|
-
};
|
|
148
|
-
describe('when no value is provided',
|
|
149
|
-
it('`throws an Error',
|
|
150
|
-
(0, chai_1.expect)(createTheValue.call({})).to.throw(Error);
|
|
138
|
+
};
|
|
139
|
+
describe('when no value is provided', () => {
|
|
140
|
+
it('`throws an Error', () => {
|
|
141
|
+
(0, chai_1.expect)(createTheValue.call({}, undefined)).to.throw(Error);
|
|
151
142
|
});
|
|
152
143
|
});
|
|
153
|
-
describe('when an invalid value is provided',
|
|
154
|
-
it('throws an Error',
|
|
144
|
+
describe('when an invalid value is provided', () => {
|
|
145
|
+
it('throws an Error', () => {
|
|
155
146
|
(0, chai_1.expect)(createTheValue(undefined)).to.throw(Error);
|
|
156
|
-
(0, chai_1.expect)(createTheValue(
|
|
147
|
+
(0, chai_1.expect)(createTheValue(() => { })).to.throw(Error);
|
|
157
148
|
});
|
|
158
149
|
});
|
|
159
150
|
});
|
|
160
151
|
});
|
|
161
|
-
describe('#eachLike',
|
|
162
|
-
describe('when content is null',
|
|
163
|
-
it('provides null as contents',
|
|
164
|
-
|
|
152
|
+
describe('#eachLike', () => {
|
|
153
|
+
describe('when content is null', () => {
|
|
154
|
+
it('provides null as contents', () => {
|
|
155
|
+
const expected = {
|
|
165
156
|
value: [null],
|
|
166
157
|
'pact:matcher:type': 'type',
|
|
167
158
|
min: 1,
|
|
168
159
|
};
|
|
169
|
-
|
|
160
|
+
const match = (0, matchers_1.eachLike)(null, { min: 1 });
|
|
170
161
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
171
162
|
});
|
|
172
163
|
});
|
|
173
|
-
describe('when an object is provided',
|
|
174
|
-
it('provides the object as contents',
|
|
175
|
-
|
|
164
|
+
describe('when an object is provided', () => {
|
|
165
|
+
it('provides the object as contents', () => {
|
|
166
|
+
const expected = {
|
|
176
167
|
value: [{ a: 1 }],
|
|
177
168
|
'pact:matcher:type': 'type',
|
|
178
169
|
min: 1,
|
|
179
170
|
};
|
|
180
|
-
|
|
171
|
+
const match = (0, matchers_1.eachLike)({ a: 1 }, { min: 1 });
|
|
181
172
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
182
173
|
});
|
|
183
174
|
});
|
|
184
|
-
describe('when object.min is invalid',
|
|
185
|
-
it('throws an Error message',
|
|
186
|
-
(0, chai_1.expect)(
|
|
175
|
+
describe('when object.min is invalid', () => {
|
|
176
|
+
it('throws an Error message', () => {
|
|
177
|
+
(0, chai_1.expect)(() => {
|
|
187
178
|
(0, matchers_1.eachLike)({ a: 1 }, { min: 0 });
|
|
188
179
|
}).to.throw(Error);
|
|
189
180
|
});
|
|
190
181
|
});
|
|
191
|
-
describe('when an array is provided',
|
|
192
|
-
it('provides the array as contents',
|
|
193
|
-
|
|
182
|
+
describe('when an array is provided', () => {
|
|
183
|
+
it('provides the array as contents', () => {
|
|
184
|
+
const expected = {
|
|
194
185
|
value: [[1, 2, 3]],
|
|
195
186
|
'pact:matcher:type': 'type',
|
|
196
187
|
min: 1,
|
|
197
188
|
};
|
|
198
|
-
|
|
189
|
+
const match = (0, matchers_1.eachLike)([1, 2, 3], { min: 1 });
|
|
199
190
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
200
191
|
});
|
|
201
192
|
});
|
|
202
|
-
describe('when a value is provided',
|
|
203
|
-
it('adds the value in contents',
|
|
204
|
-
|
|
193
|
+
describe('when a value is provided', () => {
|
|
194
|
+
it('adds the value in contents', () => {
|
|
195
|
+
const expected = {
|
|
205
196
|
value: ['test'],
|
|
206
197
|
'pact:matcher:type': 'type',
|
|
207
198
|
min: 1,
|
|
208
199
|
};
|
|
209
|
-
|
|
200
|
+
const match = (0, matchers_1.eachLike)('test', { min: 1 });
|
|
210
201
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
211
202
|
});
|
|
212
203
|
});
|
|
213
|
-
describe('when the content has Pact.Macters',
|
|
214
|
-
describe('of type somethingLike',
|
|
215
|
-
it('nests somethingLike correctly',
|
|
216
|
-
|
|
204
|
+
describe('when the content has Pact.Macters', () => {
|
|
205
|
+
describe('of type somethingLike', () => {
|
|
206
|
+
it('nests somethingLike correctly', () => {
|
|
207
|
+
const expected = {
|
|
217
208
|
value: [
|
|
218
209
|
{
|
|
219
210
|
id: {
|
|
@@ -225,13 +216,13 @@ describe('Matcher', function () {
|
|
|
225
216
|
'pact:matcher:type': 'type',
|
|
226
217
|
min: 1,
|
|
227
218
|
};
|
|
228
|
-
|
|
219
|
+
const match = (0, matchers_1.eachLike)({ id: (0, matchers_1.somethingLike)(10) }, { min: 1 });
|
|
229
220
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
230
221
|
});
|
|
231
222
|
});
|
|
232
|
-
describe('of type term',
|
|
233
|
-
it('nests term correctly',
|
|
234
|
-
|
|
223
|
+
describe('of type term', () => {
|
|
224
|
+
it('nests term correctly', () => {
|
|
225
|
+
const expected = {
|
|
235
226
|
value: [
|
|
236
227
|
{
|
|
237
228
|
colour: {
|
|
@@ -244,7 +235,7 @@ describe('Matcher', function () {
|
|
|
244
235
|
'pact:matcher:type': 'type',
|
|
245
236
|
min: 1,
|
|
246
237
|
};
|
|
247
|
-
|
|
238
|
+
const match = (0, matchers_1.eachLike)({
|
|
248
239
|
colour: (0, matchers_1.term)({
|
|
249
240
|
generate: 'red',
|
|
250
241
|
matcher: 'red|green',
|
|
@@ -254,9 +245,9 @@ describe('Matcher', function () {
|
|
|
254
245
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
255
246
|
});
|
|
256
247
|
});
|
|
257
|
-
describe('of type eachLike',
|
|
258
|
-
it('nests eachlike in contents',
|
|
259
|
-
|
|
248
|
+
describe('of type eachLike', () => {
|
|
249
|
+
it('nests eachlike in contents', () => {
|
|
250
|
+
const expected = {
|
|
260
251
|
value: [
|
|
261
252
|
{
|
|
262
253
|
value: ['blue'],
|
|
@@ -267,13 +258,13 @@ describe('Matcher', function () {
|
|
|
267
258
|
'pact:matcher:type': 'type',
|
|
268
259
|
min: 1,
|
|
269
260
|
};
|
|
270
|
-
|
|
261
|
+
const match = (0, matchers_1.eachLike)((0, matchers_1.eachLike)('blue', { min: 1 }), { min: 1 });
|
|
271
262
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
272
263
|
});
|
|
273
264
|
});
|
|
274
|
-
describe('complex object with multiple Pact.Matchers',
|
|
275
|
-
it('nests objects correctly',
|
|
276
|
-
|
|
265
|
+
describe('complex object with multiple Pact.Matchers', () => {
|
|
266
|
+
it('nests objects correctly', () => {
|
|
267
|
+
const expected = {
|
|
277
268
|
value: [
|
|
278
269
|
{
|
|
279
270
|
value: [
|
|
@@ -322,7 +313,7 @@ describe('Matcher', function () {
|
|
|
322
313
|
'pact:matcher:type': 'type',
|
|
323
314
|
min: 1,
|
|
324
315
|
};
|
|
325
|
-
|
|
316
|
+
const match = (0, matchers_1.eachLike)((0, matchers_1.eachLike)({
|
|
326
317
|
colour: (0, matchers_1.term)({ generate: 'red', matcher: 'red|green|blue' }),
|
|
327
318
|
size: (0, matchers_1.somethingLike)(10),
|
|
328
319
|
tag: (0, matchers_1.eachLike)([(0, matchers_1.somethingLike)('jumper'), (0, matchers_1.somethingLike)('shirt')], { min: 2 }),
|
|
@@ -331,214 +322,214 @@ describe('Matcher', function () {
|
|
|
331
322
|
});
|
|
332
323
|
});
|
|
333
324
|
});
|
|
334
|
-
describe('When no options.min is not provided',
|
|
335
|
-
it('defaults to a min of 1',
|
|
336
|
-
|
|
325
|
+
describe('When no options.min is not provided', () => {
|
|
326
|
+
it('defaults to a min of 1', () => {
|
|
327
|
+
const expected = {
|
|
337
328
|
value: [{ a: 1 }],
|
|
338
329
|
'pact:matcher:type': 'type',
|
|
339
330
|
min: 1,
|
|
340
331
|
};
|
|
341
|
-
|
|
332
|
+
const match = (0, matchers_1.eachLike)({ a: 1 });
|
|
342
333
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
343
334
|
});
|
|
344
335
|
});
|
|
345
|
-
describe('When a options.min is provided',
|
|
346
|
-
it('provides the object as contents',
|
|
347
|
-
|
|
336
|
+
describe('When a options.min is provided', () => {
|
|
337
|
+
it('provides the object as contents', () => {
|
|
338
|
+
const expected = {
|
|
348
339
|
value: [{ a: 1 }, { a: 1 }, { a: 1 }],
|
|
349
340
|
'pact:matcher:type': 'type',
|
|
350
341
|
min: 3,
|
|
351
342
|
};
|
|
352
|
-
|
|
343
|
+
const match = (0, matchers_1.eachLike)({ a: 1 }, { min: 3 });
|
|
353
344
|
(0, chai_1.expect)(JSON.stringify(match)).to.deep.include(JSON.stringify(expected));
|
|
354
345
|
});
|
|
355
346
|
});
|
|
356
347
|
});
|
|
357
|
-
describe('#email',
|
|
358
|
-
describe('when given a valid Email address',
|
|
359
|
-
it('creates a valid matcher',
|
|
348
|
+
describe('#email', () => {
|
|
349
|
+
describe('when given a valid Email address', () => {
|
|
350
|
+
it('creates a valid matcher', () => {
|
|
360
351
|
(0, chai_1.expect)((0, matchers_1.email)('hello@world.com')).to.be.an('object');
|
|
361
352
|
(0, chai_1.expect)((0, matchers_1.email)('hello@world.com.au')).to.be.an('object');
|
|
362
353
|
(0, chai_1.expect)((0, matchers_1.email)('hello@a.co')).to.be.an('object');
|
|
363
354
|
(0, chai_1.expect)((0, matchers_1.email)()).to.be.an('object');
|
|
364
355
|
});
|
|
365
356
|
});
|
|
366
|
-
describe('when given an invalid Email address',
|
|
367
|
-
it('returns an error',
|
|
368
|
-
(0, chai_1.expect)(
|
|
357
|
+
describe('when given an invalid Email address', () => {
|
|
358
|
+
it('returns an error', () => {
|
|
359
|
+
(0, chai_1.expect)(() => {
|
|
369
360
|
(0, matchers_1.email)('hello.world.c');
|
|
370
361
|
}).to.throw(Error);
|
|
371
362
|
});
|
|
372
363
|
});
|
|
373
364
|
});
|
|
374
|
-
describe('#uuid',
|
|
375
|
-
describe('when given a valid UUID',
|
|
376
|
-
it('creates a valid matcher',
|
|
365
|
+
describe('#uuid', () => {
|
|
366
|
+
describe('when given a valid UUID', () => {
|
|
367
|
+
it('creates a valid matcher', () => {
|
|
377
368
|
(0, chai_1.expect)((0, matchers_1.uuid)('ce118b6e-d8e1-11e7-9296-cec278b6b50a')).to.be.an('object');
|
|
378
369
|
(0, chai_1.expect)((0, matchers_1.uuid)()).to.be.an('object');
|
|
379
370
|
});
|
|
380
371
|
});
|
|
381
|
-
describe('when given an invalid UUID',
|
|
382
|
-
it('returns an error',
|
|
383
|
-
(0, chai_1.expect)(
|
|
372
|
+
describe('when given an invalid UUID', () => {
|
|
373
|
+
it('returns an error', () => {
|
|
374
|
+
(0, chai_1.expect)(() => {
|
|
384
375
|
(0, matchers_1.uuid)('abc');
|
|
385
376
|
}).to.throw(Error);
|
|
386
377
|
});
|
|
387
378
|
});
|
|
388
379
|
});
|
|
389
|
-
describe('#ipv4Address',
|
|
390
|
-
describe('when given a valid ipv4Address',
|
|
391
|
-
it('creates a valid matcher',
|
|
380
|
+
describe('#ipv4Address', () => {
|
|
381
|
+
describe('when given a valid ipv4Address', () => {
|
|
382
|
+
it('creates a valid matcher', () => {
|
|
392
383
|
(0, chai_1.expect)((0, matchers_1.ipv4Address)('127.0.0.1')).to.be.an('object');
|
|
393
384
|
(0, chai_1.expect)((0, matchers_1.ipv4Address)()).to.be.an('object');
|
|
394
385
|
});
|
|
395
386
|
});
|
|
396
|
-
describe('when given an invalid ipv4Address',
|
|
397
|
-
it('returns an error',
|
|
398
|
-
(0, chai_1.expect)(
|
|
387
|
+
describe('when given an invalid ipv4Address', () => {
|
|
388
|
+
it('returns an error', () => {
|
|
389
|
+
(0, chai_1.expect)(() => {
|
|
399
390
|
(0, matchers_1.ipv4Address)('abc');
|
|
400
391
|
}).to.throw(Error);
|
|
401
392
|
});
|
|
402
393
|
});
|
|
403
394
|
});
|
|
404
|
-
describe('#ipv6Address',
|
|
405
|
-
describe('when given a valid ipv6Address',
|
|
406
|
-
it('creates a valid matcher',
|
|
395
|
+
describe('#ipv6Address', () => {
|
|
396
|
+
describe('when given a valid ipv6Address', () => {
|
|
397
|
+
it('creates a valid matcher', () => {
|
|
407
398
|
(0, chai_1.expect)((0, matchers_1.ipv6Address)('::1')).to.be.an('object');
|
|
408
399
|
(0, chai_1.expect)((0, matchers_1.ipv6Address)('2001:0db8:85a3:0000:0000:8a2e:0370:7334')).to.be.an('object');
|
|
409
400
|
(0, chai_1.expect)((0, matchers_1.ipv6Address)()).to.be.an('object');
|
|
410
401
|
});
|
|
411
402
|
});
|
|
412
|
-
describe('when given an invalid ipv6Address',
|
|
413
|
-
it('returns an error',
|
|
414
|
-
(0, chai_1.expect)(
|
|
403
|
+
describe('when given an invalid ipv6Address', () => {
|
|
404
|
+
it('returns an error', () => {
|
|
405
|
+
(0, chai_1.expect)(() => {
|
|
415
406
|
(0, matchers_1.ipv6Address)('abc');
|
|
416
407
|
}).to.throw(Error);
|
|
417
408
|
});
|
|
418
409
|
});
|
|
419
410
|
});
|
|
420
|
-
describe('#hexadecimal',
|
|
421
|
-
describe('when given a valid hexadecimal',
|
|
422
|
-
it('creates a valid matcher',
|
|
411
|
+
describe('#hexadecimal', () => {
|
|
412
|
+
describe('when given a valid hexadecimal', () => {
|
|
413
|
+
it('creates a valid matcher', () => {
|
|
423
414
|
(0, chai_1.expect)((0, matchers_1.hexadecimal)('6F')).to.be.an('object');
|
|
424
415
|
(0, chai_1.expect)((0, matchers_1.hexadecimal)()).to.be.an('object');
|
|
425
416
|
});
|
|
426
417
|
});
|
|
427
|
-
describe('when given an invalid hexadecimal',
|
|
428
|
-
it('returns an error',
|
|
429
|
-
(0, chai_1.expect)(
|
|
418
|
+
describe('when given an invalid hexadecimal', () => {
|
|
419
|
+
it('returns an error', () => {
|
|
420
|
+
(0, chai_1.expect)(() => {
|
|
430
421
|
(0, matchers_1.hexadecimal)('x1');
|
|
431
422
|
}).to.throw(Error);
|
|
432
423
|
});
|
|
433
424
|
});
|
|
434
425
|
});
|
|
435
|
-
describe('#boolean',
|
|
436
|
-
describe('when used it should create a JSON object',
|
|
437
|
-
it('creates a valid matcher',
|
|
426
|
+
describe('#boolean', () => {
|
|
427
|
+
describe('when used it should create a JSON object', () => {
|
|
428
|
+
it('creates a valid matcher', () => {
|
|
438
429
|
(0, chai_1.expect)((0, matchers_1.boolean)()).to.be.an('object');
|
|
439
430
|
(0, chai_1.expect)((0, matchers_1.boolean)().value).to.equal(true);
|
|
440
431
|
});
|
|
441
|
-
it('sets value=false',
|
|
432
|
+
it('sets value=false', () => {
|
|
442
433
|
(0, chai_1.expect)((0, matchers_1.boolean)(false)).to.be.an('object');
|
|
443
434
|
(0, chai_1.expect)((0, matchers_1.boolean)(false).value).to.equal(false);
|
|
444
435
|
});
|
|
445
|
-
it('sets value=true',
|
|
436
|
+
it('sets value=true', () => {
|
|
446
437
|
(0, chai_1.expect)((0, matchers_1.boolean)(true)).to.be.an('object');
|
|
447
438
|
(0, chai_1.expect)((0, matchers_1.boolean)(true).value).to.equal(true);
|
|
448
439
|
});
|
|
449
440
|
});
|
|
450
441
|
});
|
|
451
|
-
describe('#string',
|
|
452
|
-
describe('when given a valid string',
|
|
453
|
-
it('creates a valid matcher',
|
|
442
|
+
describe('#string', () => {
|
|
443
|
+
describe('when given a valid string', () => {
|
|
444
|
+
it('creates a valid matcher', () => {
|
|
454
445
|
(0, chai_1.expect)((0, matchers_1.string)('test')).to.be.an('object');
|
|
455
446
|
(0, chai_1.expect)((0, matchers_1.string)()).to.be.an('object');
|
|
456
447
|
(0, chai_1.expect)((0, matchers_1.string)('test').value).to.equal('test');
|
|
457
448
|
});
|
|
458
449
|
});
|
|
459
450
|
});
|
|
460
|
-
describe('#decimal',
|
|
461
|
-
describe('when given a valid decimal',
|
|
462
|
-
it('creates a valid matcher',
|
|
451
|
+
describe('#decimal', () => {
|
|
452
|
+
describe('when given a valid decimal', () => {
|
|
453
|
+
it('creates a valid matcher', () => {
|
|
463
454
|
(0, chai_1.expect)((0, matchers_1.decimal)(10.1)).to.be.an('object');
|
|
464
455
|
(0, chai_1.expect)((0, matchers_1.decimal)()).to.be.an('object');
|
|
465
456
|
(0, chai_1.expect)((0, matchers_1.decimal)(0.0).value).to.equal(0.0);
|
|
466
457
|
});
|
|
467
458
|
});
|
|
468
459
|
});
|
|
469
|
-
describe('#integer',
|
|
470
|
-
describe('when given a valid integer',
|
|
471
|
-
it('creates a valid matcher',
|
|
460
|
+
describe('#integer', () => {
|
|
461
|
+
describe('when given a valid integer', () => {
|
|
462
|
+
it('creates a valid matcher', () => {
|
|
472
463
|
(0, chai_1.expect)((0, matchers_1.integer)(10)).to.be.an('object');
|
|
473
464
|
(0, chai_1.expect)((0, matchers_1.integer)()).to.be.an('object');
|
|
474
465
|
(0, chai_1.expect)((0, matchers_1.integer)(0).value).to.equal(0);
|
|
475
466
|
});
|
|
476
467
|
});
|
|
477
468
|
});
|
|
478
|
-
describe('Date Matchers',
|
|
479
|
-
describe('#rfc1123Timestamp',
|
|
480
|
-
describe('when given a valid rfc1123Timestamp',
|
|
481
|
-
it('creates a valid matcher',
|
|
469
|
+
describe('Date Matchers', () => {
|
|
470
|
+
describe('#rfc1123Timestamp', () => {
|
|
471
|
+
describe('when given a valid rfc1123Timestamp', () => {
|
|
472
|
+
it('creates a valid matcher', () => {
|
|
482
473
|
(0, chai_1.expect)((0, matchers_1.rfc1123Timestamp)('Mon, 31 Oct 2016 15:21:41 -0400')).to.be.an('object');
|
|
483
474
|
(0, chai_1.expect)((0, matchers_1.rfc1123Timestamp)()).to.be.an('object');
|
|
484
475
|
});
|
|
485
476
|
});
|
|
486
|
-
describe('when given an invalid rfc1123Timestamp',
|
|
487
|
-
it('returns an error',
|
|
488
|
-
(0, chai_1.expect)(
|
|
477
|
+
describe('when given an invalid rfc1123Timestamp', () => {
|
|
478
|
+
it('returns an error', () => {
|
|
479
|
+
(0, chai_1.expect)(() => {
|
|
489
480
|
(0, matchers_1.rfc1123Timestamp)('abc');
|
|
490
481
|
}).to.throw(Error);
|
|
491
482
|
});
|
|
492
483
|
});
|
|
493
484
|
});
|
|
494
|
-
describe('#iso8601Time',
|
|
495
|
-
describe('when given a valid iso8601Time',
|
|
496
|
-
it('creates a valid matcher',
|
|
485
|
+
describe('#iso8601Time', () => {
|
|
486
|
+
describe('when given a valid iso8601Time', () => {
|
|
487
|
+
it('creates a valid matcher', () => {
|
|
497
488
|
(0, chai_1.expect)((0, matchers_1.iso8601Time)('T22:44:30.652Z')).to.be.an('object');
|
|
498
489
|
(0, chai_1.expect)((0, matchers_1.iso8601Time)()).to.be.an('object');
|
|
499
490
|
});
|
|
500
491
|
});
|
|
501
|
-
describe('when given an invalid iso8601Time',
|
|
502
|
-
it('returns an error',
|
|
503
|
-
(0, chai_1.expect)(
|
|
492
|
+
describe('when given an invalid iso8601Time', () => {
|
|
493
|
+
it('returns an error', () => {
|
|
494
|
+
(0, chai_1.expect)(() => {
|
|
504
495
|
(0, matchers_1.iso8601Time)('abc');
|
|
505
496
|
}).to.throw(Error);
|
|
506
497
|
});
|
|
507
498
|
});
|
|
508
499
|
});
|
|
509
|
-
describe('#iso8601Date',
|
|
510
|
-
describe('when given a valid iso8601Date',
|
|
511
|
-
it('creates a valid matcher',
|
|
500
|
+
describe('#iso8601Date', () => {
|
|
501
|
+
describe('when given a valid iso8601Date', () => {
|
|
502
|
+
it('creates a valid matcher', () => {
|
|
512
503
|
(0, chai_1.expect)((0, matchers_1.iso8601Date)('2017-12-05')).to.be.an('object');
|
|
513
504
|
(0, chai_1.expect)((0, matchers_1.iso8601Date)()).to.be.an('object');
|
|
514
505
|
});
|
|
515
506
|
});
|
|
516
|
-
describe('when given an invalid iso8601Date',
|
|
517
|
-
it('returns an error',
|
|
518
|
-
(0, chai_1.expect)(
|
|
507
|
+
describe('when given an invalid iso8601Date', () => {
|
|
508
|
+
it('returns an error', () => {
|
|
509
|
+
(0, chai_1.expect)(() => {
|
|
519
510
|
(0, matchers_1.iso8601Date)('abc');
|
|
520
511
|
}).to.throw(Error);
|
|
521
512
|
});
|
|
522
513
|
});
|
|
523
514
|
});
|
|
524
|
-
describe('#iso8601DateTime',
|
|
525
|
-
describe('when given a valid iso8601DateTime',
|
|
526
|
-
it('creates a valid matcher',
|
|
515
|
+
describe('#iso8601DateTime', () => {
|
|
516
|
+
describe('when given a valid iso8601DateTime', () => {
|
|
517
|
+
it('creates a valid matcher', () => {
|
|
527
518
|
(0, chai_1.expect)((0, matchers_1.iso8601DateTime)('2015-08-06T16:53:10+01:00')).to.be.an('object');
|
|
528
519
|
(0, chai_1.expect)((0, matchers_1.iso8601DateTime)()).to.be.an('object');
|
|
529
520
|
});
|
|
530
521
|
});
|
|
531
|
-
describe('when given an invalid iso8601DateTime',
|
|
532
|
-
it('returns an error',
|
|
533
|
-
(0, chai_1.expect)(
|
|
522
|
+
describe('when given an invalid iso8601DateTime', () => {
|
|
523
|
+
it('returns an error', () => {
|
|
524
|
+
(0, chai_1.expect)(() => {
|
|
534
525
|
(0, matchers_1.iso8601DateTime)('abc');
|
|
535
526
|
}).to.throw(Error);
|
|
536
527
|
});
|
|
537
528
|
});
|
|
538
529
|
});
|
|
539
|
-
describe('#iso8601DateTimeWithMillis',
|
|
540
|
-
describe('when given a valid iso8601DateTimeWithMillis',
|
|
541
|
-
it('creates a valid matcher',
|
|
530
|
+
describe('#iso8601DateTimeWithMillis', () => {
|
|
531
|
+
describe('when given a valid iso8601DateTimeWithMillis', () => {
|
|
532
|
+
it('creates a valid matcher', () => {
|
|
542
533
|
(0, chai_1.expect)((0, matchers_1.iso8601DateTimeWithMillis)('2015-08-06T16:53:10.123+01:00')).to.be.an('object');
|
|
543
534
|
(0, chai_1.expect)((0, matchers_1.iso8601DateTimeWithMillis)('2015-08-06T16:53:10.537357Z')).to.be.an('object');
|
|
544
535
|
(0, chai_1.expect)((0, matchers_1.iso8601DateTimeWithMillis)('2020-12-10T09:01:29.06Z')).to.be.an('object');
|
|
@@ -546,17 +537,17 @@ describe('Matcher', function () {
|
|
|
546
537
|
(0, chai_1.expect)((0, matchers_1.iso8601DateTimeWithMillis)()).to.be.an('object');
|
|
547
538
|
});
|
|
548
539
|
});
|
|
549
|
-
describe('when given an invalid iso8601DateTimeWithMillis',
|
|
550
|
-
it('returns an error',
|
|
551
|
-
(0, chai_1.expect)(
|
|
540
|
+
describe('when given an invalid iso8601DateTimeWithMillis', () => {
|
|
541
|
+
it('returns an error', () => {
|
|
542
|
+
(0, chai_1.expect)(() => {
|
|
552
543
|
(0, matchers_1.iso8601DateTimeWithMillis)('abc');
|
|
553
544
|
}).to.throw(Error);
|
|
554
545
|
});
|
|
555
546
|
});
|
|
556
547
|
});
|
|
557
|
-
describe('#extractPayload',
|
|
558
|
-
describe('when given an object with no matchers',
|
|
559
|
-
|
|
548
|
+
describe('#extractPayload', () => {
|
|
549
|
+
describe('when given an object with no matchers', () => {
|
|
550
|
+
const object = {
|
|
560
551
|
some: 'data',
|
|
561
552
|
more: 'strings',
|
|
562
553
|
an: ['array'],
|
|
@@ -565,12 +556,12 @@ describe('Matcher', function () {
|
|
|
565
556
|
withNumber: 1,
|
|
566
557
|
},
|
|
567
558
|
};
|
|
568
|
-
it('returns just that object',
|
|
559
|
+
it('returns just that object', () => {
|
|
569
560
|
(0, chai_1.expect)((0, matchers_1.extractPayload)(object)).to.deep.equal(object);
|
|
570
561
|
});
|
|
571
562
|
});
|
|
572
|
-
describe('when given an object with null values',
|
|
573
|
-
|
|
563
|
+
describe('when given an object with null values', () => {
|
|
564
|
+
const object = {
|
|
574
565
|
some: 'data',
|
|
575
566
|
more: null,
|
|
576
567
|
an: [null],
|
|
@@ -580,12 +571,12 @@ describe('Matcher', function () {
|
|
|
580
571
|
andNull: null,
|
|
581
572
|
},
|
|
582
573
|
};
|
|
583
|
-
it('returns just that object',
|
|
574
|
+
it('returns just that object', () => {
|
|
584
575
|
(0, chai_1.expect)((0, matchers_1.extractPayload)(object)).to.deep.equal(object);
|
|
585
576
|
});
|
|
586
577
|
});
|
|
587
|
-
describe('when given an object with some matchers',
|
|
588
|
-
|
|
578
|
+
describe('when given an object with some matchers', () => {
|
|
579
|
+
const someMatchers = {
|
|
589
580
|
some: (0, matchers_1.somethingLike)('data'),
|
|
590
581
|
more: 'strings',
|
|
591
582
|
an: ['array'],
|
|
@@ -597,7 +588,7 @@ describe('Matcher', function () {
|
|
|
597
588
|
withAnotherNumber: (0, matchers_1.somethingLike)(2),
|
|
598
589
|
},
|
|
599
590
|
};
|
|
600
|
-
|
|
591
|
+
const expected = {
|
|
601
592
|
some: 'data',
|
|
602
593
|
more: 'strings',
|
|
603
594
|
an: ['array'],
|
|
@@ -609,14 +600,14 @@ describe('Matcher', function () {
|
|
|
609
600
|
withAnotherNumber: 2,
|
|
610
601
|
},
|
|
611
602
|
};
|
|
612
|
-
it('returns without matching guff',
|
|
603
|
+
it('returns without matching guff', () => {
|
|
613
604
|
(0, chai_1.expect)((0, matchers_1.extractPayload)(someMatchers)).to.deep.equal(expected);
|
|
614
605
|
});
|
|
615
606
|
});
|
|
616
|
-
describe('when given a simple matcher',
|
|
617
|
-
it('removes all matching guff',
|
|
618
|
-
|
|
619
|
-
|
|
607
|
+
describe('when given a simple matcher', () => {
|
|
608
|
+
it('removes all matching guff', () => {
|
|
609
|
+
const expected = 'myawesomeword';
|
|
610
|
+
const matcher = (0, matchers_1.term)({
|
|
620
611
|
generate: 'myawesomeword',
|
|
621
612
|
matcher: '\\w+',
|
|
622
613
|
});
|
|
@@ -624,9 +615,9 @@ describe('Matcher', function () {
|
|
|
624
615
|
(0, chai_1.expect)((0, matchers_1.extractPayload)(matcher)).to.eql(expected);
|
|
625
616
|
});
|
|
626
617
|
});
|
|
627
|
-
describe('when given a complex nested object with matchers',
|
|
628
|
-
it('removes all matching guff',
|
|
629
|
-
|
|
618
|
+
describe('when given a complex nested object with matchers', () => {
|
|
619
|
+
it('removes all matching guff', () => {
|
|
620
|
+
const o = (0, matchers_1.somethingLike)({
|
|
630
621
|
stringMatcher: {
|
|
631
622
|
awesomeSetting: (0, matchers_1.somethingLike)('a string'),
|
|
632
623
|
},
|
|
@@ -646,7 +637,7 @@ describe('Matcher', function () {
|
|
|
646
637
|
}, { min: 3 }),
|
|
647
638
|
},
|
|
648
639
|
});
|
|
649
|
-
|
|
640
|
+
const expected = {
|
|
650
641
|
stringMatcher: {
|
|
651
642
|
awesomeSetting: 'a string',
|
|
652
643
|
},
|