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