@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.
Files changed (261) hide show
  1. package/CHANGELOG.md +23 -0
  2. package/CONTRIBUTING.md +2 -2
  3. package/README.md +22 -12
  4. package/package.json +26 -47
  5. package/scripts/ci/build-and-test.sh +0 -3
  6. package/scripts/install-plugins.js +104 -0
  7. package/src/common/graphQL/configurationError.js +2 -22
  8. package/src/common/graphQL/configurationError.js.map +1 -1
  9. package/src/common/graphQL/graphQL.d.ts +2 -2
  10. package/src/common/graphQL/graphQL.js +11 -14
  11. package/src/common/graphQL/graphQL.js.map +1 -1
  12. package/src/common/graphQL/graphQLQueryError.js +2 -22
  13. package/src/common/graphQL/graphQLQueryError.js.map +1 -1
  14. package/src/common/logger.js +9 -9
  15. package/src/common/logger.js.map +1 -1
  16. package/src/common/matchingRules.d.ts +7 -1
  17. package/src/common/matchingRules.js +42 -22
  18. package/src/common/matchingRules.js.map +1 -1
  19. package/src/common/net.js +36 -42
  20. package/src/common/net.js.map +1 -1
  21. package/src/common/net.spec.js +39 -87
  22. package/src/common/net.spec.js.map +1 -1
  23. package/src/common/request.js +33 -82
  24. package/src/common/request.js.map +1 -1
  25. package/src/common/request.spec.js +29 -73
  26. package/src/common/request.spec.js.map +1 -1
  27. package/src/common/spec.js +3 -4
  28. package/src/common/spec.js.map +1 -1
  29. package/src/dsl/apolloGraphql.js +7 -25
  30. package/src/dsl/apolloGraphql.js.map +1 -1
  31. package/src/dsl/apolloGraphql.spec.js +21 -58
  32. package/src/dsl/apolloGraphql.spec.js.map +1 -1
  33. package/src/dsl/graphql.d.ts +2 -2
  34. package/src/dsl/graphql.js +29 -48
  35. package/src/dsl/graphql.js.map +1 -1
  36. package/src/dsl/graphql.spec.js +92 -117
  37. package/src/dsl/graphql.spec.js.map +1 -1
  38. package/src/dsl/interaction.d.ts +2 -2
  39. package/src/dsl/interaction.js +41 -48
  40. package/src/dsl/interaction.js.map +1 -1
  41. package/src/dsl/interaction.spec.js +109 -132
  42. package/src/dsl/interaction.spec.js.map +1 -1
  43. package/src/dsl/matchers.d.ts +2 -3
  44. package/src/dsl/matchers.js +19 -31
  45. package/src/dsl/matchers.js.map +1 -1
  46. package/src/dsl/matchers.spec.js +279 -289
  47. package/src/dsl/matchers.spec.js.map +1 -1
  48. package/src/dsl/message.d.ts +3 -3
  49. package/src/dsl/options.d.ts +3 -3
  50. package/src/dsl/verifier/proxy/hooks.d.ts +2 -2
  51. package/src/dsl/verifier/proxy/hooks.js +42 -112
  52. package/src/dsl/verifier/proxy/hooks.js.map +1 -1
  53. package/src/dsl/verifier/proxy/hooks.spec.js +86 -199
  54. package/src/dsl/verifier/proxy/hooks.spec.js.map +1 -1
  55. package/src/dsl/verifier/proxy/messages.d.ts +2 -2
  56. package/src/dsl/verifier/proxy/messages.js +88 -106
  57. package/src/dsl/verifier/proxy/messages.js.map +1 -1
  58. package/src/dsl/verifier/proxy/parseBody.d.ts +1 -1
  59. package/src/dsl/verifier/proxy/parseBody.js +3 -3
  60. package/src/dsl/verifier/proxy/parseBody.js.map +1 -1
  61. package/src/dsl/verifier/proxy/parseBody.spec.js +35 -113
  62. package/src/dsl/verifier/proxy/parseBody.spec.js.map +1 -1
  63. package/src/dsl/verifier/proxy/proxy.d.ts +2 -2
  64. package/src/dsl/verifier/proxy/proxy.js +22 -26
  65. package/src/dsl/verifier/proxy/proxy.js.map +1 -1
  66. package/src/dsl/verifier/proxy/proxy.spec.js +11 -53
  67. package/src/dsl/verifier/proxy/proxy.spec.js.map +1 -1
  68. package/src/dsl/verifier/proxy/proxyRequest.d.ts +3 -3
  69. package/src/dsl/verifier/proxy/proxyRequest.js +7 -7
  70. package/src/dsl/verifier/proxy/proxyRequest.js.map +1 -1
  71. package/src/dsl/verifier/proxy/proxyRequest.spec.js +54 -104
  72. package/src/dsl/verifier/proxy/proxyRequest.spec.js.map +1 -1
  73. package/src/dsl/verifier/proxy/stateHandler/setupStates.d.ts +3 -3
  74. package/src/dsl/verifier/proxy/stateHandler/setupStates.js +14 -18
  75. package/src/dsl/verifier/proxy/stateHandler/setupStates.js.map +1 -1
  76. package/src/dsl/verifier/proxy/stateHandler/setupStates.spec.js +76 -193
  77. package/src/dsl/verifier/proxy/stateHandler/setupStates.spec.js.map +1 -1
  78. package/src/dsl/verifier/proxy/stateHandler/stateHandler.d.ts +2 -2
  79. package/src/dsl/verifier/proxy/stateHandler/stateHandler.js +23 -72
  80. package/src/dsl/verifier/proxy/stateHandler/stateHandler.js.map +1 -1
  81. package/src/dsl/verifier/proxy/stateHandler/stateHandler.spec.js +37 -122
  82. package/src/dsl/verifier/proxy/stateHandler/stateHandler.spec.js.map +1 -1
  83. package/src/dsl/verifier/proxy/tracer.d.ts +1 -1
  84. package/src/dsl/verifier/proxy/tracer.js +42 -35
  85. package/src/dsl/verifier/proxy/tracer.js.map +1 -1
  86. package/src/dsl/verifier/proxy/types.d.ts +5 -5
  87. package/src/dsl/verifier/types.d.ts +3 -3
  88. package/src/dsl/verifier/verifier.d.ts +5 -1
  89. package/src/dsl/verifier/verifier.js +53 -60
  90. package/src/dsl/verifier/verifier.js.map +1 -1
  91. package/src/dsl/verifier/verifier.spec.js +84 -151
  92. package/src/dsl/verifier/verifier.spec.js.map +1 -1
  93. package/src/errors/configurationError.js +2 -22
  94. package/src/errors/configurationError.js.map +1 -1
  95. package/src/errors/graphQLQueryError.js +2 -22
  96. package/src/errors/graphQLQueryError.js.map +1 -1
  97. package/src/errors/matcherError.js +2 -22
  98. package/src/errors/matcherError.js.map +1 -1
  99. package/src/errors/verificationError.js +2 -22
  100. package/src/errors/verificationError.js.map +1 -1
  101. package/src/httpPact/ffi.d.ts +2 -2
  102. package/src/httpPact/ffi.js +28 -29
  103. package/src/httpPact/ffi.js.map +1 -1
  104. package/src/httpPact/ffi.spec.js +40 -83
  105. package/src/httpPact/ffi.spec.js.map +1 -1
  106. package/src/httpPact/index.d.ts +3 -3
  107. package/src/httpPact/index.js +92 -149
  108. package/src/httpPact/index.js.map +1 -1
  109. package/src/httpPact/index.spec.js +102 -195
  110. package/src/httpPact/index.spec.js.map +1 -1
  111. package/src/httpPact/tracing.js +20 -28
  112. package/src/httpPact/tracing.js.map +1 -1
  113. package/src/index.d.ts +25 -25
  114. package/src/index.js +29 -29
  115. package/src/index.js.map +1 -1
  116. package/src/messageConsumerPact.d.ts +5 -5
  117. package/src/messageConsumerPact.js +59 -53
  118. package/src/messageConsumerPact.js.map +1 -1
  119. package/src/messageConsumerPact.spec.js +55 -97
  120. package/src/messageConsumerPact.spec.js.map +1 -1
  121. package/src/messageProviderPact.d.ts +3 -3
  122. package/src/messageProviderPact.js +68 -85
  123. package/src/messageProviderPact.js.map +1 -1
  124. package/src/messageProviderPact.spec.js +96 -123
  125. package/src/messageProviderPact.spec.js.map +1 -1
  126. package/src/pact.integration.spec.js +242 -351
  127. package/src/pact.integration.spec.js.map +1 -1
  128. package/src/v3/display.d.ts +1 -1
  129. package/src/v3/display.js +44 -58
  130. package/src/v3/display.js.map +1 -1
  131. package/src/v3/ffi.js +20 -16
  132. package/src/v3/ffi.js.map +1 -1
  133. package/src/v3/ffi.spec.js +7 -42
  134. package/src/v3/ffi.spec.js.map +1 -1
  135. package/src/v3/graphql/graphQL.d.ts +4 -4
  136. package/src/v3/graphql/graphQL.js +50 -75
  137. package/src/v3/graphql/graphQL.js.map +1 -1
  138. package/src/v3/graphql/index.d.ts +1 -1
  139. package/src/v3/graphql/index.js +1 -1
  140. package/src/v3/graphql/index.js.map +1 -1
  141. package/src/v3/index.d.ts +4 -12
  142. package/src/v3/index.js +4 -12
  143. package/src/v3/index.js.map +1 -1
  144. package/src/v3/matchers.d.ts +15 -3
  145. package/src/v3/matchers.js +131 -148
  146. package/src/v3/matchers.js.map +1 -1
  147. package/src/v3/matchers.spec.js +281 -232
  148. package/src/v3/matchers.spec.js.map +1 -1
  149. package/src/v3/pact.d.ts +2 -2
  150. package/src/v3/pact.js +108 -151
  151. package/src/v3/pact.js.map +1 -1
  152. package/src/v3/pact.spec.js +94 -0
  153. package/src/v3/pact.spec.js.map +1 -0
  154. package/src/v3/types.d.ts +19 -3
  155. package/src/v3/types.js +22 -1
  156. package/src/v3/types.js.map +1 -1
  157. package/src/v4/graphql/graphQLInteractionWithRequest.d.ts +4 -4
  158. package/src/v4/graphql/graphQLInteractionWithRequest.js +21 -17
  159. package/src/v4/graphql/graphQLInteractionWithRequest.js.map +1 -1
  160. package/src/v4/graphql/graphQLRequestBuilder.d.ts +3 -3
  161. package/src/v4/graphql/graphQLRequestBuilder.js +18 -20
  162. package/src/v4/graphql/graphQLRequestBuilder.js.map +1 -1
  163. package/src/v4/graphql/index.d.ts +6 -6
  164. package/src/v4/graphql/index.js +21 -17
  165. package/src/v4/graphql/index.js.map +1 -1
  166. package/src/v4/graphql/types.d.ts +5 -5
  167. package/src/v4/http/index.d.ts +2 -2
  168. package/src/v4/http/index.js +53 -93
  169. package/src/v4/http/index.js.map +1 -1
  170. package/src/v4/http/index.spec.d.ts +1 -0
  171. package/src/v4/http/index.spec.js +73 -0
  172. package/src/v4/http/index.spec.js.map +1 -0
  173. package/src/v4/http/interactionWithCompleteRequest.d.ts +4 -7
  174. package/src/v4/http/interactionWithCompleteRequest.js +6 -10
  175. package/src/v4/http/interactionWithCompleteRequest.js.map +1 -1
  176. package/src/v4/http/interactionWithPlugin.d.ts +3 -3
  177. package/src/v4/http/interactionWithPlugin.js +14 -11
  178. package/src/v4/http/interactionWithPlugin.js.map +1 -1
  179. package/src/v4/http/interactionWithPluginRequest.d.ts +4 -3
  180. package/src/v4/http/interactionWithPluginRequest.js +17 -9
  181. package/src/v4/http/interactionWithPluginRequest.js.map +1 -1
  182. package/src/v4/http/interactionWithPluginResponse.d.ts +2 -2
  183. package/src/v4/http/interactionWithPluginResponse.js +10 -48
  184. package/src/v4/http/interactionWithPluginResponse.js.map +1 -1
  185. package/src/v4/http/interactionWithRequest.d.ts +4 -3
  186. package/src/v4/http/interactionWithRequest.js +17 -9
  187. package/src/v4/http/interactionWithRequest.js.map +1 -1
  188. package/src/v4/http/interactionWithRequest.spec.d.ts +1 -0
  189. package/src/v4/http/interactionWithRequest.spec.js +82 -0
  190. package/src/v4/http/interactionWithRequest.spec.js.map +1 -0
  191. package/src/v4/http/interactionWithResponse.d.ts +2 -2
  192. package/src/v4/http/interactionWithResponse.js +10 -48
  193. package/src/v4/http/interactionWithResponse.js.map +1 -1
  194. package/src/v4/http/requestBuilder.d.ts +4 -3
  195. package/src/v4/http/requestBuilder.js +36 -34
  196. package/src/v4/http/requestBuilder.js.map +1 -1
  197. package/src/v4/http/requestBuilder.spec.d.ts +1 -0
  198. package/src/v4/http/requestBuilder.spec.js +42 -0
  199. package/src/v4/http/requestBuilder.spec.js.map +1 -0
  200. package/src/v4/http/requestWithPluginBuilder.d.ts +3 -2
  201. package/src/v4/http/requestWithPluginBuilder.js +30 -46
  202. package/src/v4/http/requestWithPluginBuilder.js.map +1 -1
  203. package/src/v4/http/requestWithPluginBuilder.spec.d.ts +1 -0
  204. package/src/v4/http/requestWithPluginBuilder.spec.js +34 -0
  205. package/src/v4/http/requestWithPluginBuilder.spec.js.map +1 -0
  206. package/src/v4/http/responseBuilder.d.ts +4 -3
  207. package/src/v4/http/responseBuilder.js +28 -25
  208. package/src/v4/http/responseBuilder.js.map +1 -1
  209. package/src/v4/http/responseBuilder.spec.d.ts +1 -0
  210. package/src/v4/http/responseBuilder.spec.js +42 -0
  211. package/src/v4/http/responseBuilder.spec.js.map +1 -0
  212. package/src/v4/http/responseWithPluginBuilder.d.ts +1 -1
  213. package/src/v4/http/responseWithPluginBuilder.js +5 -25
  214. package/src/v4/http/responseWithPluginBuilder.js.map +1 -1
  215. package/src/v4/http/responseWithPluginBuilder.spec.d.ts +1 -0
  216. package/src/v4/http/responseWithPluginBuilder.spec.js +34 -0
  217. package/src/v4/http/responseWithPluginBuilder.spec.js.map +1 -0
  218. package/src/v4/http/types.d.ts +13 -4
  219. package/src/v4/http/unconfiguredInteraction.d.ts +6 -5
  220. package/src/v4/http/unconfiguredInteraction.js +31 -26
  221. package/src/v4/http/unconfiguredInteraction.js.map +1 -1
  222. package/src/v4/index.d.ts +6 -5
  223. package/src/v4/index.js +32 -35
  224. package/src/v4/index.js.map +1 -1
  225. package/src/v4/message/asynchronousMessage.d.ts +7 -6
  226. package/src/v4/message/asynchronousMessage.js +157 -190
  227. package/src/v4/message/asynchronousMessage.js.map +1 -1
  228. package/src/v4/message/index.d.ts +7 -6
  229. package/src/v4/message/index.js +188 -217
  230. package/src/v4/message/index.js.map +1 -1
  231. package/src/v4/message/types.d.ts +5 -3
  232. package/src/v4/types.d.ts +3 -3
  233. package/src/xml/index.d.ts +4 -0
  234. package/src/xml/index.js +21 -0
  235. package/src/xml/index.js.map +1 -0
  236. package/src/{v3/xml → xml}/xmlBuilder.d.ts +1 -3
  237. package/src/{v3/xml → xml}/xmlBuilder.js +7 -9
  238. package/src/xml/xmlBuilder.js.map +1 -0
  239. package/src/{v3/xml → xml}/xmlElement.d.ts +2 -2
  240. package/src/xml/xmlElement.js +73 -0
  241. package/src/xml/xmlElement.js.map +1 -0
  242. package/src/xml/xmlElement.spec.d.ts +1 -0
  243. package/src/xml/xmlElement.spec.js +107 -0
  244. package/src/xml/xmlElement.spec.js.map +1 -0
  245. package/src/xml/xmlNode.js +7 -0
  246. package/src/xml/xmlNode.js.map +1 -0
  247. package/src/{v3/xml → xml}/xmlText.d.ts +1 -1
  248. package/src/xml/xmlText.js +15 -0
  249. package/src/xml/xmlText.js.map +1 -0
  250. package/scripts/install-plugins +0 -106
  251. package/src/v3/xml/xmlBuilder.js.map +0 -1
  252. package/src/v3/xml/xmlElement.js +0 -90
  253. package/src/v3/xml/xmlElement.js.map +0 -1
  254. package/src/v3/xml/xmlElement.spec.js +0 -113
  255. package/src/v3/xml/xmlElement.spec.js.map +0 -1
  256. package/src/v3/xml/xmlNode.js +0 -10
  257. package/src/v3/xml/xmlNode.js.map +0 -1
  258. package/src/v3/xml/xmlText.js +0 -31
  259. package/src/v3/xml/xmlText.js.map +0 -1
  260. /package/src/v3/{xml/xmlElement.spec.d.ts → pact.spec.d.ts} +0 -0
  261. /package/src/{v3/xml → xml}/xmlNode.d.ts +0 -0
@@ -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
- var chai = __importStar(require("chai"));
48
- var MatchersV3 = __importStar(require("./matchers"));
49
- var expect = chai.expect;
50
- describe('V3 Matchers', function () {
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(__assign({}, f));
41
+ MatchersV3.like({ ...f });
55
42
  MatchersV3.like(Object.freeze(f));
56
- var r = { id: 'some guid', foo: { a: 'example' } };
43
+ const r = { id: 'some guid', foo: { a: 'example' } };
57
44
  MatchersV3.like(r);
58
- MatchersV3.like(__assign({}, r));
45
+ MatchersV3.like({ ...r });
59
46
  MatchersV3.like(Object.freeze(f));
60
47
  MatchersV3.reify(r);
61
48
  });
62
- describe('#like', function () {
63
- it('returns a JSON representation of a like matcher', function () {
64
- var result = MatchersV3.like({
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).to.deep.equal({
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', function () {
76
- it('returns a JSON representation of an eachKeyLike matcher', function () {
77
- var result = MatchersV3.eachKeyLike('004', {
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).to.deep.equal({
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', function () {
91
- describe('with no min', function () {
92
- it('returns a JSON representation of an eachLike matcher', function () {
93
- var result = MatchersV3.eachLike({
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).to.deep.equal({
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', function () {
108
- it('returns a JSON representation of an eachLike matcher', function () {
109
- var result = MatchersV3.eachLike({
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).to.deep.equal({
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', function () {
131
- describe('with no examples', function () {
132
- it('returns a JSON representation of an atLeastOneLike matcher', function () {
133
- var result = MatchersV3.atLeastOneLike({
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).to.deep.equal({
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', function () {
148
- it('returns a JSON representation of an atLeastOneLike matcher with the correct number of examples', function () {
149
- var result = MatchersV3.atLeastOneLike({
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).to.deep.equal({
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', function () {
161
- describe('with no examples', function () {
162
- it('returns a JSON representation of an atLeastLike matcher', function () {
163
- var result = MatchersV3.atLeastLike({
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).to.deep.equal({
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', function () {
174
- it('returns a JSON representation of an atLeastLike matcher with the correct number of examples', function () {
175
- var result = MatchersV3.atLeastLike({
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).to.deep.equal({
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', function () {
186
- expect(function () { return MatchersV3.atLeastLike({ a: 'b' }, 4, 2); }).to.throw('atLeastLike has a minimum of 4 but 2 elements were requested. Make sure the count is greater than or equal to the min.');
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', function () {
190
- describe('with no examples', function () {
191
- it('returns a JSON representation of an atMostLike matcher', function () {
192
- var result = MatchersV3.atMostLike({
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).to.deep.equal({
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', function () {
203
- it('returns a JSON representation of an atMostLike matcher with the correct number of examples', function () {
204
- var result = MatchersV3.atMostLike({
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).to.deep.equal({
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', function () {
215
- expect(function () { return MatchersV3.atMostLike({ a: 'b' }, 2, 4); }).to.throw('atMostLike has a maximum of 2 but 4 elements where requested. Make sure the count is less than or equal to the max.');
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', function () {
219
- describe('with no examples', function () {
220
- it('returns a JSON representation of an constrainedArrayLike matcher', function () {
221
- var result = MatchersV3.constrainedArrayLike({
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).to.deep.equal({
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', function () {
233
- it('returns a JSON representation of an constrainedArrayLike matcher with the correct number of examples', function () {
234
- var result = MatchersV3.constrainedArrayLike({
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).to.deep.equal({
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', function () {
246
- expect(function () {
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', function () {
251
- expect(function () {
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', function () {
257
- it('returns a JSON representation of an integer matcher', function () {
258
- var result = MatchersV3.integer(100);
259
- expect(result).to.deep.equal({
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', function () {
265
- it('returns a JSON representation of an integer matcher', function () {
266
- var result = MatchersV3.integer(0);
267
- expect(result).to.deep.equal({
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', function () {
274
- it('also includes a random integer generator', function () {
275
- var result = MatchersV3.integer();
276
- expect(result).to.deep.equal({
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', function () {
285
- it('returns a JSON representation of an decimal matcher', function () {
286
- var result = MatchersV3.decimal(100.3);
287
- expect(result).to.deep.equal({
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', function () {
293
- it('returns a JSON representation of an integer matcher', function () {
294
- var result = MatchersV3.decimal(0.0);
295
- expect(result).to.deep.equal({
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', function () {
302
- it('also includes a random decimal generator', function () {
303
- var result = MatchersV3.decimal();
304
- expect(result).to.deep.equal({
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', function () {
313
- it('returns a JSON representation of an number matcher', function () {
314
- var result = MatchersV3.number(100.3);
315
- expect(result).to.deep.equal({
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', function () {
321
- it('also includes a random integer generator', function () {
322
- var result = MatchersV3.number();
323
- expect(result).to.deep.equal({
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', function () {
332
- it('returns a JSON representation of a like matcher', function () {
333
- var result = MatchersV3.boolean(true);
334
- expect(result).to.deep.equal({
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', function () {
341
- it('returns a JSON representation of a like matcher', function () {
342
- var result = MatchersV3.string('true');
343
- expect(result).to.deep.equal({
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', function () {
350
- it('returns a JSON representation of a regex matcher', function () {
351
- var result = MatchersV3.regex('\\d+', '1234');
352
- expect(result).to.deep.equal({
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', function () {
359
- it('returns a JSON representation of a regex matcher', function () {
360
- var result = MatchersV3.regex(/\d+/, '1234');
361
- expect(result).to.deep.equal({
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', function () {
370
- it('returns a JSON representation of an equality matcher', function () {
371
- var result = MatchersV3.equal('true');
372
- expect(result).to.deep.equal({
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', function () {
379
- describe('when an example is given', function () {
380
- it('returns a JSON representation of a datetime matcher', function () {
381
- var result = MatchersV3.datetime("yyyy-MM-dd'T'HH:mm:ss.SSSX", '2016-02-11T09:46:56.023Z');
382
- expect(result).to.deep.equal({
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', function () {
390
- it('throws an error', function () {
391
- expect(function () {
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', function () {
398
- describe('when an example is given', function () {
399
- it('returns a JSON representation of a time matcher', function () {
400
- var result = MatchersV3.time('HH:mm:ss', '09:46:56');
401
- expect(result).to.deep.equal({
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', function () {
409
- it('throws an error', function () {
410
- expect(function () { return MatchersV3.time('HH:mm:ss', ''); }).to.throw('you must provide an example time');
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', function () {
415
- describe('when an example is given', function () {
416
- it('returns a JSON representation of a date matcher', function () {
417
- var result = MatchersV3.date('yyyy-MM-dd', '2016-02-11');
418
- expect(result).to.deep.equal({
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', function () {
426
- it('throws an error', function () {
427
- expect(function () { return MatchersV3.date('yyyy-MM-dd', ''); }).to.throw('you must provide an example date');
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', function () {
432
- it('returns a JSON representation of an include matcher', function () {
433
- var result = MatchersV3.includes('true');
434
- expect(result).to.deep.equal({
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', function () {
441
- it('returns a JSON representation of an null matcher', function () {
442
- var result = MatchersV3.nullValue();
443
- expect(result).to.deep.equal({
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', function () {
450
- it('returns a JSON representation of a regex matcher for the URL', function () {
451
- var result = MatchersV3.url2('http://localhost:8080', [
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).to.deep.equal({
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', function () {
464
- it('returns a JSON representation of a regex matcher for the URL', function () {
465
- var result = MatchersV3.url2('http://localhost:8080', [
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).to.deep.equal({
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', function () {
479
- it('returns a JSON representation of a regex matcher for the URL', function () {
480
- var result = MatchersV3.url2('http://localhost:8080', [
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).to.deep.contain({
467
+ expect(result).toMatchObject({
487
468
  'pact:matcher:type': 'regex',
488
469
  regex: '.*(\\/users\\/\\d+\\/posts\\/latest)$',
489
470
  });
490
- expect(result.value).to.match(/\/users\/\d+\/posts\/latest$/);
471
+ expect(result.value).toMatch(/\/users\/\d+\/posts\/latest$/);
491
472
  });
492
473
  });
493
- describe('when no base URL is provided', function () {
494
- it('returns regex matcher and a MockServerURL generator', function () {
495
- var result = MatchersV3.url([
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).to.deep.equal({
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', function () {
512
- it('returns a JSON representation of an regex matcher for UUIDs', function () {
513
- var result = MatchersV3.uuid('ba4bd1bc-5556-11eb-9286-d71bc5b507be');
514
- expect(result).to.deep.equal({
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', function () {
521
- expect(function () { return MatchersV3.uuid('not a uuid'); }).to.throw();
522
- expect(function () { return MatchersV3.uuid('ba4bd1bc-5556-11eb-9286'); }).to.throw();
523
- expect(function () {
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', function () {
528
- var result = MatchersV3.uuid();
529
- expect(result).to.deep.equal({
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', function () {
538
- describe('when given an object with no matchers', function () {
539
- var object = {
540
- value: 'data', // field name of value should not be only determination of isMatcher()
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', function () {
549
- expect(MatchersV3.reify(object)).to.deep.equal(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', function () {
553
- var object = {
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', function () {
564
- expect(MatchersV3.reify(object)).to.deep.equal(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', function () {
568
- var someMatchers = {
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
- var expected = {
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', function () {
595
- expect(MatchersV3.reify(someMatchers)).to.deep.equal(expected);
573
+ it('returns without matching guff', () => {
574
+ expect(MatchersV3.reify(someMatchers)).toEqual(expected);
596
575
  });
597
576
  });
598
- describe('when given a simple matcher', function () {
599
- it('removes all matching guff', function () {
600
- var expected = 'myawesomeword';
601
- var matcher = MatchersV3.regex('\\w+', 'myawesomeword');
602
- expect(MatchersV3.isMatcher(matcher)).to.eq(true);
603
- expect(MatchersV3.reify(matcher)).to.eql(expected);
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', function () {
607
- it('removes all matching guff', function () {
608
- var o = MatchersV3.like({
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
- var expected = {
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)).to.deep.equal(expected);
637
+ expect(MatchersV3.reify(o)).toEqual(expected);
659
638
  });
660
639
  });
661
- describe('when given a matcher and field named "value"', function () {
662
- it('should not be isMatcher"', function () {
663
- var resultMatcher = MatchersV3.like({
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
- var result = MatchersV3.reify(resultMatcher);
668
- expect(result).to.deep.equal({
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