@wordpress/jest-console 5.3.0 → 6.0.1-next.957ca95e4c.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 CHANGED
@@ -2,6 +2,12 @@
2
2
 
3
3
  ## Unreleased
4
4
 
5
+ ## 6.0.0 (2022-08-24)
6
+
7
+ ### Breaking Change
8
+
9
+ - Increase the minimum Node.js version to 14 ([#43141](https://github.com/WordPress/gutenberg/pull/43141)).
10
+
5
11
  ## 5.1.0 (2022-05-18)
6
12
 
7
13
  ### Enhancements
package/README.md CHANGED
@@ -18,7 +18,7 @@ Install the module:
18
18
  npm install @wordpress/jest-console --save-dev
19
19
  ```
20
20
 
21
- **Note**: This package requires Node.js 12.0.0 or later. It is not compatible with older versions.
21
+ **Note**: This package requires Node.js 14.0.0 or later. It is not compatible with older versions.
22
22
 
23
23
  ### Setup
24
24
 
package/build/index.js CHANGED
@@ -2,16 +2,10 @@
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
4
 
5
- var _lodash = require("lodash");
6
-
7
5
  require("./matchers");
8
6
 
9
7
  var _supportedMatchers = _interopRequireDefault(require("./supported-matchers"));
10
8
 
11
- /**
12
- * External dependencies
13
- */
14
-
15
9
  /**
16
10
  * Internal dependencies
17
11
  */
@@ -19,10 +13,12 @@ var _supportedMatchers = _interopRequireDefault(require("./supported-matchers"))
19
13
  /**
20
14
  * Sets spy on the console object's method to make it possible to fail test when method called without assertion.
21
15
  *
22
- * @param {string} matcherName Name of Jest matcher.
23
- * @param {string} methodName Name of console method.
16
+ * @param {Array} args
17
+ * @param {string} args."0" Name of console method.
18
+ * @param {string} args."1" Name of Jest matcher.
24
19
  */
25
- const setConsoleMethodSpy = (matcherName, methodName) => {
20
+ const setConsoleMethodSpy = _ref => {
21
+ let [methodName, matcherName] = _ref;
26
22
  const spy = jest.spyOn(console, methodName).mockName(`console.${methodName}`);
27
23
  /**
28
24
  * Resets the spy to its initial state.
@@ -51,5 +47,5 @@ const setConsoleMethodSpy = (matcherName, methodName) => {
51
47
  afterEach(assertExpectedCalls);
52
48
  };
53
49
 
54
- (0, _lodash.forEach)(_supportedMatchers.default, setConsoleMethodSpy);
50
+ Object.entries(_supportedMatchers.default).forEach(setConsoleMethodSpy);
55
51
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/jest-console/src/index.js"],"names":["setConsoleMethodSpy","matcherName","methodName","spy","jest","spyOn","console","mockName","resetSpy","mockReset","assertionsNumber","assertExpectedCalls","mock","calls","length","expect","not","beforeAll","beforeEach","afterEach","supportedMatchers"],"mappings":";;;;AAGA;;AAKA;;AACA;;AATA;AACA;AACA;;AAGA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG,CAAEC,WAAF,EAAeC,UAAf,KAA+B;AAC1D,QAAMC,GAAG,GAAGC,IAAI,CACdC,KADU,CACHC,OADG,EACMJ,UADN,EAEVK,QAFU,CAEC,WAAWL,UAAY,EAFxB,CAAZ;AAIA;AACD;AACA;;AACC,WAASM,QAAT,GAAoB;AACnBL,IAAAA,GAAG,CAACM,SAAJ;AACAN,IAAAA,GAAG,CAACO,gBAAJ,GAAuB,CAAvB;AACA;AAED;AACD;AACA;;;AACC,WAASC,mBAAT,GAA+B;AAC9B,QAAKR,GAAG,CAACO,gBAAJ,KAAyB,CAAzB,IAA8BP,GAAG,CAACS,IAAJ,CAASC,KAAT,CAAeC,MAAf,GAAwB,CAA3D,EAA+D;AAC9DC,MAAAA,MAAM,CAAET,OAAF,CAAN,CAAkBU,GAAlB,CAAuBf,WAAvB;AACA;AACD;;AAEDgB,EAAAA,SAAS,CAAET,QAAF,CAAT;AAEAU,EAAAA,UAAU,CAAE,MAAM;AACjBP,IAAAA,mBAAmB;AACnBH,IAAAA,QAAQ;AACR,GAHS,CAAV;AAKAW,EAAAA,SAAS,CAAER,mBAAF,CAAT;AACA,CA9BD;;AAgCA,qBAASS,0BAAT,EAA4BpB,mBAA5B","sourcesContent":["/**\n * External dependencies\n */\nimport { forEach } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport './matchers';\nimport supportedMatchers from './supported-matchers';\n\n/**\n * Sets spy on the console object's method to make it possible to fail test when method called without assertion.\n *\n * @param {string} matcherName Name of Jest matcher.\n * @param {string} methodName Name of console method.\n */\nconst setConsoleMethodSpy = ( matcherName, methodName ) => {\n\tconst spy = jest\n\t\t.spyOn( console, methodName )\n\t\t.mockName( `console.${ methodName }` );\n\n\t/**\n\t * Resets the spy to its initial state.\n\t */\n\tfunction resetSpy() {\n\t\tspy.mockReset();\n\t\tspy.assertionsNumber = 0;\n\t}\n\n\t/**\n\t * Verifies that the spy has only been called if expected.\n\t */\n\tfunction assertExpectedCalls() {\n\t\tif ( spy.assertionsNumber === 0 && spy.mock.calls.length > 0 ) {\n\t\t\texpect( console ).not[ matcherName ]();\n\t\t}\n\t}\n\n\tbeforeAll( resetSpy );\n\n\tbeforeEach( () => {\n\t\tassertExpectedCalls();\n\t\tresetSpy();\n\t} );\n\n\tafterEach( assertExpectedCalls );\n};\n\nforEach( supportedMatchers, setConsoleMethodSpy );\n"]}
1
+ {"version":3,"sources":["@wordpress/jest-console/src/index.js"],"names":["setConsoleMethodSpy","methodName","matcherName","spy","jest","spyOn","console","mockName","resetSpy","mockReset","assertionsNumber","assertExpectedCalls","mock","calls","length","expect","not","beforeAll","beforeEach","afterEach","Object","entries","supportedMatchers","forEach"],"mappings":";;;;AAGA;;AACA;;AAJA;AACA;AACA;;AAIA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,MAAMA,mBAAmB,GAAG,QAAmC;AAAA,MAAjC,CAAEC,UAAF,EAAcC,WAAd,CAAiC;AAC9D,QAAMC,GAAG,GAAGC,IAAI,CACdC,KADU,CACHC,OADG,EACML,UADN,EAEVM,QAFU,CAEC,WAAWN,UAAY,EAFxB,CAAZ;AAIA;AACD;AACA;;AACC,WAASO,QAAT,GAAoB;AACnBL,IAAAA,GAAG,CAACM,SAAJ;AACAN,IAAAA,GAAG,CAACO,gBAAJ,GAAuB,CAAvB;AACA;AAED;AACD;AACA;;;AACC,WAASC,mBAAT,GAA+B;AAC9B,QAAKR,GAAG,CAACO,gBAAJ,KAAyB,CAAzB,IAA8BP,GAAG,CAACS,IAAJ,CAASC,KAAT,CAAeC,MAAf,GAAwB,CAA3D,EAA+D;AAC9DC,MAAAA,MAAM,CAAET,OAAF,CAAN,CAAkBU,GAAlB,CAAuBd,WAAvB;AACA;AACD;;AAEDe,EAAAA,SAAS,CAAET,QAAF,CAAT;AAEAU,EAAAA,UAAU,CAAE,MAAM;AACjBP,IAAAA,mBAAmB;AACnBH,IAAAA,QAAQ;AACR,GAHS,CAAV;AAKAW,EAAAA,SAAS,CAAER,mBAAF,CAAT;AACA,CA9BD;;AAgCAS,MAAM,CAACC,OAAP,CAAgBC,0BAAhB,EAAoCC,OAApC,CAA6CvB,mBAA7C","sourcesContent":["/**\n * Internal dependencies\n */\nimport './matchers';\nimport supportedMatchers from './supported-matchers';\n\n/**\n * Sets spy on the console object's method to make it possible to fail test when method called without assertion.\n *\n * @param {Array} args\n * @param {string} args.\"0\" Name of console method.\n * @param {string} args.\"1\" Name of Jest matcher.\n */\nconst setConsoleMethodSpy = ( [ methodName, matcherName ] ) => {\n\tconst spy = jest\n\t\t.spyOn( console, methodName )\n\t\t.mockName( `console.${ methodName }` );\n\n\t/**\n\t * Resets the spy to its initial state.\n\t */\n\tfunction resetSpy() {\n\t\tspy.mockReset();\n\t\tspy.assertionsNumber = 0;\n\t}\n\n\t/**\n\t * Verifies that the spy has only been called if expected.\n\t */\n\tfunction assertExpectedCalls() {\n\t\tif ( spy.assertionsNumber === 0 && spy.mock.calls.length > 0 ) {\n\t\t\texpect( console ).not[ matcherName ]();\n\t\t}\n\t}\n\n\tbeforeAll( resetSpy );\n\n\tbeforeEach( () => {\n\t\tassertExpectedCalls();\n\t\tresetSpy();\n\t} );\n\n\tafterEach( assertExpectedCalls );\n};\n\nObject.entries( supportedMatchers ).forEach( setConsoleMethodSpy );\n"]}
package/build/matchers.js CHANGED
@@ -4,8 +4,6 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
 
5
5
  var _jestMatcherUtils = require("jest-matcher-utils");
6
6
 
7
- var _lodash = require("lodash");
8
-
9
7
  var _supportedMatchers = _interopRequireDefault(require("./supported-matchers"));
10
8
 
11
9
  /**
@@ -34,7 +32,7 @@ const createToHaveBeenCalledWith = (matcherName, methodName) => function (receiv
34
32
 
35
33
  const spy = received[methodName];
36
34
  const calls = spy.mock.calls;
37
- const pass = (0, _lodash.some)(calls, objects => (0, _lodash.isEqual)(objects, expected));
35
+ const pass = calls.some(objects => this.equals(objects, expected));
38
36
  const message = pass ? () => (0, _jestMatcherUtils.matcherHint)(`.not${matcherName}`, spy.getMockName()) + '\n\n' + 'Expected mock function not to be called with:\n' + (0, _jestMatcherUtils.printExpected)(expected) : () => (0, _jestMatcherUtils.matcherHint)(matcherName, spy.getMockName()) + '\n\n' + 'Expected mock function to be called with:\n' + (0, _jestMatcherUtils.printExpected)(expected) + '\n' + 'but it was called with:\n' + calls.map(_jestMatcherUtils.printReceived);
39
37
  spy.assertionsNumber += 1;
40
38
  return {
@@ -43,7 +41,8 @@ const createToHaveBeenCalledWith = (matcherName, methodName) => function (receiv
43
41
  };
44
42
  };
45
43
 
46
- expect.extend((0, _lodash.reduce)(_supportedMatchers.default, (result, matcherName, methodName) => {
44
+ expect.extend(Object.entries(_supportedMatchers.default).reduce((result, _ref) => {
45
+ let [methodName, matcherName] = _ref;
47
46
  const matcherNameWith = `${matcherName}With`;
48
47
  return { ...result,
49
48
  [matcherName]: createToHaveBeenCalledMatcher(`.${matcherName}`, methodName),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/jest-console/src/matchers.js"],"names":["createToHaveBeenCalledMatcher","matcherName","methodName","received","spy","calls","mock","pass","length","message","getMockName","map","printReceived","assertionsNumber","createToHaveBeenCalledWith","expected","objects","expect","extend","supportedMatchers","result","matcherNameWith"],"mappings":";;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGA,MAAMA,6BAA6B,GAClC,CAAEC,WAAF,EAAeC,UAAf,KAAiCC,QAAF,IAAgB;AAC9C,QAAMC,GAAG,GAAGD,QAAQ,CAAED,UAAF,CAApB;AACA,QAAMG,KAAK,GAAGD,GAAG,CAACE,IAAJ,CAASD,KAAvB;AACA,QAAME,IAAI,GAAGF,KAAK,CAACG,MAAN,GAAe,CAA5B;AACA,QAAMC,OAAO,GAAGF,IAAI,GACjB,MACA,mCAAc,OAAON,WAAa,EAAlC,EAAqCG,GAAG,CAACM,WAAJ,EAArC,IACA,MADA,GAEA,mEAFA,GAGAL,KAAK,CAACM,GAAN,CAAWC,+BAAX,CALiB,GAMjB,MACA,mCAAaX,WAAb,EAA0BG,GAAG,CAACM,WAAJ,EAA1B,IACA,MADA,GAEA,sCATH;AAWAN,EAAAA,GAAG,CAACS,gBAAJ,IAAwB,CAAxB;AAEA,SAAO;AACNJ,IAAAA,OADM;AAENF,IAAAA;AAFM,GAAP;AAIA,CAtBF;;AAwBA,MAAMO,0BAA0B,GAC/B,CAAEb,WAAF,EAAeC,UAAf,KACA,UAAEC,QAAF,EAA6B;AAAA,oCAAdY,QAAc;AAAdA,IAAAA,QAAc;AAAA;;AAC5B,QAAMX,GAAG,GAAGD,QAAQ,CAAED,UAAF,CAApB;AACA,QAAMG,KAAK,GAAGD,GAAG,CAACE,IAAJ,CAASD,KAAvB;AACA,QAAME,IAAI,GAAG,kBAAMF,KAAN,EAAeW,OAAF,IAAe,qBAASA,OAAT,EAAkBD,QAAlB,CAA5B,CAAb;AACA,QAAMN,OAAO,GAAGF,IAAI,GACjB,MACA,mCAAc,OAAON,WAAa,EAAlC,EAAqCG,GAAG,CAACM,WAAJ,EAArC,IACA,MADA,GAEA,iDAFA,GAGA,qCAAeK,QAAf,CALiB,GAMjB,MACA,mCAAad,WAAb,EAA0BG,GAAG,CAACM,WAAJ,EAA1B,IACA,MADA,GAEA,6CAFA,GAGA,qCAAeK,QAAf,CAHA,GAIA,IAJA,GAKA,2BALA,GAMAV,KAAK,CAACM,GAAN,CAAWC,+BAAX,CAbH;AAeAR,EAAAA,GAAG,CAACS,gBAAJ,IAAwB,CAAxB;AAEA,SAAO;AACNJ,IAAAA,OADM;AAENF,IAAAA;AAFM,GAAP;AAIA,CA3BF;;AA6BAU,MAAM,CAACC,MAAP,CACC,oBACCC,0BADD,EAEC,CAAEC,MAAF,EAAUnB,WAAV,EAAuBC,UAAvB,KAAuC;AACtC,QAAMmB,eAAe,GAAI,GAAGpB,WAAa,MAAzC;AAEA,SAAO,EACN,GAAGmB,MADG;AAEN,KAAEnB,WAAF,GAAiBD,6BAA6B,CAC5C,IAAIC,WAAa,EAD2B,EAE7CC,UAF6C,CAFxC;AAMN,KAAEmB,eAAF,GAAqBP,0BAA0B,CAC7C,IAAIO,eAAiB,EADwB,EAE9CnB,UAF8C;AANzC,GAAP;AAWA,CAhBF,EAiBC,EAjBD,CADD","sourcesContent":["/**\n * External dependencies\n */\nimport { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';\nimport { isEqual, reduce, some } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport supportedMatchers from './supported-matchers';\n\nconst createToHaveBeenCalledMatcher =\n\t( matcherName, methodName ) => ( received ) => {\n\t\tconst spy = received[ methodName ];\n\t\tconst calls = spy.mock.calls;\n\t\tconst pass = calls.length > 0;\n\t\tconst message = pass\n\t\t\t? () =>\n\t\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function not to be called but it was called with:\\n' +\n\t\t\t\t\tcalls.map( printReceived )\n\t\t\t: () =>\n\t\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function to be called.';\n\n\t\tspy.assertionsNumber += 1;\n\n\t\treturn {\n\t\t\tmessage,\n\t\t\tpass,\n\t\t};\n\t};\n\nconst createToHaveBeenCalledWith =\n\t( matcherName, methodName ) =>\n\t( received, ...expected ) => {\n\t\tconst spy = received[ methodName ];\n\t\tconst calls = spy.mock.calls;\n\t\tconst pass = some( calls, ( objects ) => isEqual( objects, expected ) );\n\t\tconst message = pass\n\t\t\t? () =>\n\t\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function not to be called with:\\n' +\n\t\t\t\t\tprintExpected( expected )\n\t\t\t: () =>\n\t\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function to be called with:\\n' +\n\t\t\t\t\tprintExpected( expected ) +\n\t\t\t\t\t'\\n' +\n\t\t\t\t\t'but it was called with:\\n' +\n\t\t\t\t\tcalls.map( printReceived );\n\n\t\tspy.assertionsNumber += 1;\n\n\t\treturn {\n\t\t\tmessage,\n\t\t\tpass,\n\t\t};\n\t};\n\nexpect.extend(\n\treduce(\n\t\tsupportedMatchers,\n\t\t( result, matcherName, methodName ) => {\n\t\t\tconst matcherNameWith = `${ matcherName }With`;\n\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\t[ matcherName ]: createToHaveBeenCalledMatcher(\n\t\t\t\t\t`.${ matcherName }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t\t[ matcherNameWith ]: createToHaveBeenCalledWith(\n\t\t\t\t\t`.${ matcherNameWith }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t{}\n\t)\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/jest-console/src/matchers.js"],"names":["createToHaveBeenCalledMatcher","matcherName","methodName","received","spy","calls","mock","pass","length","message","getMockName","map","printReceived","assertionsNumber","createToHaveBeenCalledWith","expected","some","objects","equals","expect","extend","Object","entries","supportedMatchers","reduce","result","matcherNameWith"],"mappings":";;;;AAGA;;AAKA;;AARA;AACA;AACA;;AAGA;AACA;AACA;AAGA,MAAMA,6BAA6B,GAClC,CAAEC,WAAF,EAAeC,UAAf,KAAiCC,QAAF,IAAgB;AAC9C,QAAMC,GAAG,GAAGD,QAAQ,CAAED,UAAF,CAApB;AACA,QAAMG,KAAK,GAAGD,GAAG,CAACE,IAAJ,CAASD,KAAvB;AACA,QAAME,IAAI,GAAGF,KAAK,CAACG,MAAN,GAAe,CAA5B;AACA,QAAMC,OAAO,GAAGF,IAAI,GACjB,MACA,mCAAc,OAAON,WAAa,EAAlC,EAAqCG,GAAG,CAACM,WAAJ,EAArC,IACA,MADA,GAEA,mEAFA,GAGAL,KAAK,CAACM,GAAN,CAAWC,+BAAX,CALiB,GAMjB,MACA,mCAAaX,WAAb,EAA0BG,GAAG,CAACM,WAAJ,EAA1B,IACA,MADA,GAEA,sCATH;AAWAN,EAAAA,GAAG,CAACS,gBAAJ,IAAwB,CAAxB;AAEA,SAAO;AACNJ,IAAAA,OADM;AAENF,IAAAA;AAFM,GAAP;AAIA,CAtBF;;AAwBA,MAAMO,0BAA0B,GAAG,CAAEb,WAAF,EAAeC,UAAf,KAClC,UAAWC,QAAX,EAAmC;AAAA,oCAAXY,QAAW;AAAXA,IAAAA,QAAW;AAAA;;AAClC,QAAMX,GAAG,GAAGD,QAAQ,CAAED,UAAF,CAApB;AACA,QAAMG,KAAK,GAAGD,GAAG,CAACE,IAAJ,CAASD,KAAvB;AACA,QAAME,IAAI,GAAGF,KAAK,CAACW,IAAN,CAAcC,OAAF,IACxB,KAAKC,MAAL,CAAaD,OAAb,EAAsBF,QAAtB,CADY,CAAb;AAGA,QAAMN,OAAO,GAAGF,IAAI,GACjB,MACA,mCAAc,OAAON,WAAa,EAAlC,EAAqCG,GAAG,CAACM,WAAJ,EAArC,IACA,MADA,GAEA,iDAFA,GAGA,qCAAeK,QAAf,CALiB,GAMjB,MACA,mCAAad,WAAb,EAA0BG,GAAG,CAACM,WAAJ,EAA1B,IACA,MADA,GAEA,6CAFA,GAGA,qCAAeK,QAAf,CAHA,GAIA,IAJA,GAKA,2BALA,GAMAV,KAAK,CAACM,GAAN,CAAWC,+BAAX,CAbH;AAeAR,EAAAA,GAAG,CAACS,gBAAJ,IAAwB,CAAxB;AAEA,SAAO;AACNJ,IAAAA,OADM;AAENF,IAAAA;AAFM,GAAP;AAIA,CA5BF;;AA8BAY,MAAM,CAACC,MAAP,CACCC,MAAM,CAACC,OAAP,CAAgBC,0BAAhB,EAAoCC,MAApC,CACC,CAAEC,MAAF,WAA2C;AAAA,MAAjC,CAAEvB,UAAF,EAAcD,WAAd,CAAiC;AAC1C,QAAMyB,eAAe,GAAI,GAAGzB,WAAa,MAAzC;AAEA,SAAO,EACN,GAAGwB,MADG;AAEN,KAAExB,WAAF,GAAiBD,6BAA6B,CAC5C,IAAIC,WAAa,EAD2B,EAE7CC,UAF6C,CAFxC;AAMN,KAAEwB,eAAF,GAAqBZ,0BAA0B,CAC7C,IAAIY,eAAiB,EADwB,EAE9CxB,UAF8C;AANzC,GAAP;AAWA,CAfF,EAgBC,EAhBD,CADD","sourcesContent":["/**\n * External dependencies\n */\nimport { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';\n\n/**\n * Internal dependencies\n */\nimport supportedMatchers from './supported-matchers';\n\nconst createToHaveBeenCalledMatcher =\n\t( matcherName, methodName ) => ( received ) => {\n\t\tconst spy = received[ methodName ];\n\t\tconst calls = spy.mock.calls;\n\t\tconst pass = calls.length > 0;\n\t\tconst message = pass\n\t\t\t? () =>\n\t\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function not to be called but it was called with:\\n' +\n\t\t\t\t\tcalls.map( printReceived )\n\t\t\t: () =>\n\t\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function to be called.';\n\n\t\tspy.assertionsNumber += 1;\n\n\t\treturn {\n\t\t\tmessage,\n\t\t\tpass,\n\t\t};\n\t};\n\nconst createToHaveBeenCalledWith = ( matcherName, methodName ) =>\n\tfunction ( received, ...expected ) {\n\t\tconst spy = received[ methodName ];\n\t\tconst calls = spy.mock.calls;\n\t\tconst pass = calls.some( ( objects ) =>\n\t\t\tthis.equals( objects, expected )\n\t\t);\n\t\tconst message = pass\n\t\t\t? () =>\n\t\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function not to be called with:\\n' +\n\t\t\t\t\tprintExpected( expected )\n\t\t\t: () =>\n\t\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function to be called with:\\n' +\n\t\t\t\t\tprintExpected( expected ) +\n\t\t\t\t\t'\\n' +\n\t\t\t\t\t'but it was called with:\\n' +\n\t\t\t\t\tcalls.map( printReceived );\n\n\t\tspy.assertionsNumber += 1;\n\n\t\treturn {\n\t\t\tmessage,\n\t\t\tpass,\n\t\t};\n\t};\n\nexpect.extend(\n\tObject.entries( supportedMatchers ).reduce(\n\t\t( result, [ methodName, matcherName ] ) => {\n\t\t\tconst matcherNameWith = `${ matcherName }With`;\n\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\t[ matcherName ]: createToHaveBeenCalledMatcher(\n\t\t\t\t\t`.${ matcherName }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t\t[ matcherNameWith ]: createToHaveBeenCalledWith(\n\t\t\t\t\t`.${ matcherNameWith }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t{}\n\t)\n);\n"]}
@@ -1,21 +1,18 @@
1
- /**
2
- * External dependencies
3
- */
4
- import { forEach } from 'lodash';
5
1
  /**
6
2
  * Internal dependencies
7
3
  */
8
-
9
4
  import './matchers';
10
5
  import supportedMatchers from './supported-matchers';
11
6
  /**
12
7
  * Sets spy on the console object's method to make it possible to fail test when method called without assertion.
13
8
  *
14
- * @param {string} matcherName Name of Jest matcher.
15
- * @param {string} methodName Name of console method.
9
+ * @param {Array} args
10
+ * @param {string} args."0" Name of console method.
11
+ * @param {string} args."1" Name of Jest matcher.
16
12
  */
17
13
 
18
- const setConsoleMethodSpy = (matcherName, methodName) => {
14
+ const setConsoleMethodSpy = _ref => {
15
+ let [methodName, matcherName] = _ref;
19
16
  const spy = jest.spyOn(console, methodName).mockName(`console.${methodName}`);
20
17
  /**
21
18
  * Resets the spy to its initial state.
@@ -44,5 +41,5 @@ const setConsoleMethodSpy = (matcherName, methodName) => {
44
41
  afterEach(assertExpectedCalls);
45
42
  };
46
43
 
47
- forEach(supportedMatchers, setConsoleMethodSpy);
44
+ Object.entries(supportedMatchers).forEach(setConsoleMethodSpy);
48
45
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/jest-console/src/index.js"],"names":["forEach","supportedMatchers","setConsoleMethodSpy","matcherName","methodName","spy","jest","spyOn","console","mockName","resetSpy","mockReset","assertionsNumber","assertExpectedCalls","mock","calls","length","expect","not","beforeAll","beforeEach","afterEach"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,OAAT,QAAwB,QAAxB;AAEA;AACA;AACA;;AACA,OAAO,YAAP;AACA,OAAOC,iBAAP,MAA8B,sBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG,CAAEC,WAAF,EAAeC,UAAf,KAA+B;AAC1D,QAAMC,GAAG,GAAGC,IAAI,CACdC,KADU,CACHC,OADG,EACMJ,UADN,EAEVK,QAFU,CAEC,WAAWL,UAAY,EAFxB,CAAZ;AAIA;AACD;AACA;;AACC,WAASM,QAAT,GAAoB;AACnBL,IAAAA,GAAG,CAACM,SAAJ;AACAN,IAAAA,GAAG,CAACO,gBAAJ,GAAuB,CAAvB;AACA;AAED;AACD;AACA;;;AACC,WAASC,mBAAT,GAA+B;AAC9B,QAAKR,GAAG,CAACO,gBAAJ,KAAyB,CAAzB,IAA8BP,GAAG,CAACS,IAAJ,CAASC,KAAT,CAAeC,MAAf,GAAwB,CAA3D,EAA+D;AAC9DC,MAAAA,MAAM,CAAET,OAAF,CAAN,CAAkBU,GAAlB,CAAuBf,WAAvB;AACA;AACD;;AAEDgB,EAAAA,SAAS,CAAET,QAAF,CAAT;AAEAU,EAAAA,UAAU,CAAE,MAAM;AACjBP,IAAAA,mBAAmB;AACnBH,IAAAA,QAAQ;AACR,GAHS,CAAV;AAKAW,EAAAA,SAAS,CAAER,mBAAF,CAAT;AACA,CA9BD;;AAgCAb,OAAO,CAAEC,iBAAF,EAAqBC,mBAArB,CAAP","sourcesContent":["/**\n * External dependencies\n */\nimport { forEach } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport './matchers';\nimport supportedMatchers from './supported-matchers';\n\n/**\n * Sets spy on the console object's method to make it possible to fail test when method called without assertion.\n *\n * @param {string} matcherName Name of Jest matcher.\n * @param {string} methodName Name of console method.\n */\nconst setConsoleMethodSpy = ( matcherName, methodName ) => {\n\tconst spy = jest\n\t\t.spyOn( console, methodName )\n\t\t.mockName( `console.${ methodName }` );\n\n\t/**\n\t * Resets the spy to its initial state.\n\t */\n\tfunction resetSpy() {\n\t\tspy.mockReset();\n\t\tspy.assertionsNumber = 0;\n\t}\n\n\t/**\n\t * Verifies that the spy has only been called if expected.\n\t */\n\tfunction assertExpectedCalls() {\n\t\tif ( spy.assertionsNumber === 0 && spy.mock.calls.length > 0 ) {\n\t\t\texpect( console ).not[ matcherName ]();\n\t\t}\n\t}\n\n\tbeforeAll( resetSpy );\n\n\tbeforeEach( () => {\n\t\tassertExpectedCalls();\n\t\tresetSpy();\n\t} );\n\n\tafterEach( assertExpectedCalls );\n};\n\nforEach( supportedMatchers, setConsoleMethodSpy );\n"]}
1
+ {"version":3,"sources":["@wordpress/jest-console/src/index.js"],"names":["supportedMatchers","setConsoleMethodSpy","methodName","matcherName","spy","jest","spyOn","console","mockName","resetSpy","mockReset","assertionsNumber","assertExpectedCalls","mock","calls","length","expect","not","beforeAll","beforeEach","afterEach","Object","entries","forEach"],"mappings":"AAAA;AACA;AACA;AACA,OAAO,YAAP;AACA,OAAOA,iBAAP,MAA8B,sBAA9B;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;;AACA,MAAMC,mBAAmB,GAAG,QAAmC;AAAA,MAAjC,CAAEC,UAAF,EAAcC,WAAd,CAAiC;AAC9D,QAAMC,GAAG,GAAGC,IAAI,CACdC,KADU,CACHC,OADG,EACML,UADN,EAEVM,QAFU,CAEC,WAAWN,UAAY,EAFxB,CAAZ;AAIA;AACD;AACA;;AACC,WAASO,QAAT,GAAoB;AACnBL,IAAAA,GAAG,CAACM,SAAJ;AACAN,IAAAA,GAAG,CAACO,gBAAJ,GAAuB,CAAvB;AACA;AAED;AACD;AACA;;;AACC,WAASC,mBAAT,GAA+B;AAC9B,QAAKR,GAAG,CAACO,gBAAJ,KAAyB,CAAzB,IAA8BP,GAAG,CAACS,IAAJ,CAASC,KAAT,CAAeC,MAAf,GAAwB,CAA3D,EAA+D;AAC9DC,MAAAA,MAAM,CAAET,OAAF,CAAN,CAAkBU,GAAlB,CAAuBd,WAAvB;AACA;AACD;;AAEDe,EAAAA,SAAS,CAAET,QAAF,CAAT;AAEAU,EAAAA,UAAU,CAAE,MAAM;AACjBP,IAAAA,mBAAmB;AACnBH,IAAAA,QAAQ;AACR,GAHS,CAAV;AAKAW,EAAAA,SAAS,CAAER,mBAAF,CAAT;AACA,CA9BD;;AAgCAS,MAAM,CAACC,OAAP,CAAgBtB,iBAAhB,EAAoCuB,OAApC,CAA6CtB,mBAA7C","sourcesContent":["/**\n * Internal dependencies\n */\nimport './matchers';\nimport supportedMatchers from './supported-matchers';\n\n/**\n * Sets spy on the console object's method to make it possible to fail test when method called without assertion.\n *\n * @param {Array} args\n * @param {string} args.\"0\" Name of console method.\n * @param {string} args.\"1\" Name of Jest matcher.\n */\nconst setConsoleMethodSpy = ( [ methodName, matcherName ] ) => {\n\tconst spy = jest\n\t\t.spyOn( console, methodName )\n\t\t.mockName( `console.${ methodName }` );\n\n\t/**\n\t * Resets the spy to its initial state.\n\t */\n\tfunction resetSpy() {\n\t\tspy.mockReset();\n\t\tspy.assertionsNumber = 0;\n\t}\n\n\t/**\n\t * Verifies that the spy has only been called if expected.\n\t */\n\tfunction assertExpectedCalls() {\n\t\tif ( spy.assertionsNumber === 0 && spy.mock.calls.length > 0 ) {\n\t\t\texpect( console ).not[ matcherName ]();\n\t\t}\n\t}\n\n\tbeforeAll( resetSpy );\n\n\tbeforeEach( () => {\n\t\tassertExpectedCalls();\n\t\tresetSpy();\n\t} );\n\n\tafterEach( assertExpectedCalls );\n};\n\nObject.entries( supportedMatchers ).forEach( setConsoleMethodSpy );\n"]}
@@ -2,7 +2,6 @@
2
2
  * External dependencies
3
3
  */
4
4
  import { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';
5
- import { isEqual, reduce, some } from 'lodash';
6
5
  /**
7
6
  * Internal dependencies
8
7
  */
@@ -28,7 +27,7 @@ const createToHaveBeenCalledWith = (matcherName, methodName) => function (receiv
28
27
 
29
28
  const spy = received[methodName];
30
29
  const calls = spy.mock.calls;
31
- const pass = some(calls, objects => isEqual(objects, expected));
30
+ const pass = calls.some(objects => this.equals(objects, expected));
32
31
  const message = pass ? () => matcherHint(`.not${matcherName}`, spy.getMockName()) + '\n\n' + 'Expected mock function not to be called with:\n' + printExpected(expected) : () => matcherHint(matcherName, spy.getMockName()) + '\n\n' + 'Expected mock function to be called with:\n' + printExpected(expected) + '\n' + 'but it was called with:\n' + calls.map(printReceived);
33
32
  spy.assertionsNumber += 1;
34
33
  return {
@@ -37,7 +36,8 @@ const createToHaveBeenCalledWith = (matcherName, methodName) => function (receiv
37
36
  };
38
37
  };
39
38
 
40
- expect.extend(reduce(supportedMatchers, (result, matcherName, methodName) => {
39
+ expect.extend(Object.entries(supportedMatchers).reduce((result, _ref) => {
40
+ let [methodName, matcherName] = _ref;
41
41
  const matcherNameWith = `${matcherName}With`;
42
42
  return { ...result,
43
43
  [matcherName]: createToHaveBeenCalledMatcher(`.${matcherName}`, methodName),
@@ -1 +1 @@
1
- {"version":3,"sources":["@wordpress/jest-console/src/matchers.js"],"names":["matcherHint","printExpected","printReceived","isEqual","reduce","some","supportedMatchers","createToHaveBeenCalledMatcher","matcherName","methodName","received","spy","calls","mock","pass","length","message","getMockName","map","assertionsNumber","createToHaveBeenCalledWith","expected","objects","expect","extend","result","matcherNameWith"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,aAAtB,EAAqCC,aAArC,QAA0D,oBAA1D;AACA,SAASC,OAAT,EAAkBC,MAAlB,EAA0BC,IAA1B,QAAsC,QAAtC;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,sBAA9B;;AAEA,MAAMC,6BAA6B,GAClC,CAAEC,WAAF,EAAeC,UAAf,KAAiCC,QAAF,IAAgB;AAC9C,QAAMC,GAAG,GAAGD,QAAQ,CAAED,UAAF,CAApB;AACA,QAAMG,KAAK,GAAGD,GAAG,CAACE,IAAJ,CAASD,KAAvB;AACA,QAAME,IAAI,GAAGF,KAAK,CAACG,MAAN,GAAe,CAA5B;AACA,QAAMC,OAAO,GAAGF,IAAI,GACjB,MACAd,WAAW,CAAG,OAAOQ,WAAa,EAAvB,EAA0BG,GAAG,CAACM,WAAJ,EAA1B,CAAX,GACA,MADA,GAEA,mEAFA,GAGAL,KAAK,CAACM,GAAN,CAAWhB,aAAX,CALiB,GAMjB,MACAF,WAAW,CAAEQ,WAAF,EAAeG,GAAG,CAACM,WAAJ,EAAf,CAAX,GACA,MADA,GAEA,sCATH;AAWAN,EAAAA,GAAG,CAACQ,gBAAJ,IAAwB,CAAxB;AAEA,SAAO;AACNH,IAAAA,OADM;AAENF,IAAAA;AAFM,GAAP;AAIA,CAtBF;;AAwBA,MAAMM,0BAA0B,GAC/B,CAAEZ,WAAF,EAAeC,UAAf,KACA,UAAEC,QAAF,EAA6B;AAAA,oCAAdW,QAAc;AAAdA,IAAAA,QAAc;AAAA;;AAC5B,QAAMV,GAAG,GAAGD,QAAQ,CAAED,UAAF,CAApB;AACA,QAAMG,KAAK,GAAGD,GAAG,CAACE,IAAJ,CAASD,KAAvB;AACA,QAAME,IAAI,GAAGT,IAAI,CAAEO,KAAF,EAAWU,OAAF,IAAenB,OAAO,CAAEmB,OAAF,EAAWD,QAAX,CAA/B,CAAjB;AACA,QAAML,OAAO,GAAGF,IAAI,GACjB,MACAd,WAAW,CAAG,OAAOQ,WAAa,EAAvB,EAA0BG,GAAG,CAACM,WAAJ,EAA1B,CAAX,GACA,MADA,GAEA,iDAFA,GAGAhB,aAAa,CAAEoB,QAAF,CALI,GAMjB,MACArB,WAAW,CAAEQ,WAAF,EAAeG,GAAG,CAACM,WAAJ,EAAf,CAAX,GACA,MADA,GAEA,6CAFA,GAGAhB,aAAa,CAAEoB,QAAF,CAHb,GAIA,IAJA,GAKA,2BALA,GAMAT,KAAK,CAACM,GAAN,CAAWhB,aAAX,CAbH;AAeAS,EAAAA,GAAG,CAACQ,gBAAJ,IAAwB,CAAxB;AAEA,SAAO;AACNH,IAAAA,OADM;AAENF,IAAAA;AAFM,GAAP;AAIA,CA3BF;;AA6BAS,MAAM,CAACC,MAAP,CACCpB,MAAM,CACLE,iBADK,EAEL,CAAEmB,MAAF,EAAUjB,WAAV,EAAuBC,UAAvB,KAAuC;AACtC,QAAMiB,eAAe,GAAI,GAAGlB,WAAa,MAAzC;AAEA,SAAO,EACN,GAAGiB,MADG;AAEN,KAAEjB,WAAF,GAAiBD,6BAA6B,CAC5C,IAAIC,WAAa,EAD2B,EAE7CC,UAF6C,CAFxC;AAMN,KAAEiB,eAAF,GAAqBN,0BAA0B,CAC7C,IAAIM,eAAiB,EADwB,EAE9CjB,UAF8C;AANzC,GAAP;AAWA,CAhBI,EAiBL,EAjBK,CADP","sourcesContent":["/**\n * External dependencies\n */\nimport { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';\nimport { isEqual, reduce, some } from 'lodash';\n\n/**\n * Internal dependencies\n */\nimport supportedMatchers from './supported-matchers';\n\nconst createToHaveBeenCalledMatcher =\n\t( matcherName, methodName ) => ( received ) => {\n\t\tconst spy = received[ methodName ];\n\t\tconst calls = spy.mock.calls;\n\t\tconst pass = calls.length > 0;\n\t\tconst message = pass\n\t\t\t? () =>\n\t\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function not to be called but it was called with:\\n' +\n\t\t\t\t\tcalls.map( printReceived )\n\t\t\t: () =>\n\t\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function to be called.';\n\n\t\tspy.assertionsNumber += 1;\n\n\t\treturn {\n\t\t\tmessage,\n\t\t\tpass,\n\t\t};\n\t};\n\nconst createToHaveBeenCalledWith =\n\t( matcherName, methodName ) =>\n\t( received, ...expected ) => {\n\t\tconst spy = received[ methodName ];\n\t\tconst calls = spy.mock.calls;\n\t\tconst pass = some( calls, ( objects ) => isEqual( objects, expected ) );\n\t\tconst message = pass\n\t\t\t? () =>\n\t\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function not to be called with:\\n' +\n\t\t\t\t\tprintExpected( expected )\n\t\t\t: () =>\n\t\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function to be called with:\\n' +\n\t\t\t\t\tprintExpected( expected ) +\n\t\t\t\t\t'\\n' +\n\t\t\t\t\t'but it was called with:\\n' +\n\t\t\t\t\tcalls.map( printReceived );\n\n\t\tspy.assertionsNumber += 1;\n\n\t\treturn {\n\t\t\tmessage,\n\t\t\tpass,\n\t\t};\n\t};\n\nexpect.extend(\n\treduce(\n\t\tsupportedMatchers,\n\t\t( result, matcherName, methodName ) => {\n\t\t\tconst matcherNameWith = `${ matcherName }With`;\n\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\t[ matcherName ]: createToHaveBeenCalledMatcher(\n\t\t\t\t\t`.${ matcherName }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t\t[ matcherNameWith ]: createToHaveBeenCalledWith(\n\t\t\t\t\t`.${ matcherNameWith }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t{}\n\t)\n);\n"]}
1
+ {"version":3,"sources":["@wordpress/jest-console/src/matchers.js"],"names":["matcherHint","printExpected","printReceived","supportedMatchers","createToHaveBeenCalledMatcher","matcherName","methodName","received","spy","calls","mock","pass","length","message","getMockName","map","assertionsNumber","createToHaveBeenCalledWith","expected","some","objects","equals","expect","extend","Object","entries","reduce","result","matcherNameWith"],"mappings":"AAAA;AACA;AACA;AACA,SAASA,WAAT,EAAsBC,aAAtB,EAAqCC,aAArC,QAA0D,oBAA1D;AAEA;AACA;AACA;;AACA,OAAOC,iBAAP,MAA8B,sBAA9B;;AAEA,MAAMC,6BAA6B,GAClC,CAAEC,WAAF,EAAeC,UAAf,KAAiCC,QAAF,IAAgB;AAC9C,QAAMC,GAAG,GAAGD,QAAQ,CAAED,UAAF,CAApB;AACA,QAAMG,KAAK,GAAGD,GAAG,CAACE,IAAJ,CAASD,KAAvB;AACA,QAAME,IAAI,GAAGF,KAAK,CAACG,MAAN,GAAe,CAA5B;AACA,QAAMC,OAAO,GAAGF,IAAI,GACjB,MACAX,WAAW,CAAG,OAAOK,WAAa,EAAvB,EAA0BG,GAAG,CAACM,WAAJ,EAA1B,CAAX,GACA,MADA,GAEA,mEAFA,GAGAL,KAAK,CAACM,GAAN,CAAWb,aAAX,CALiB,GAMjB,MACAF,WAAW,CAAEK,WAAF,EAAeG,GAAG,CAACM,WAAJ,EAAf,CAAX,GACA,MADA,GAEA,sCATH;AAWAN,EAAAA,GAAG,CAACQ,gBAAJ,IAAwB,CAAxB;AAEA,SAAO;AACNH,IAAAA,OADM;AAENF,IAAAA;AAFM,GAAP;AAIA,CAtBF;;AAwBA,MAAMM,0BAA0B,GAAG,CAAEZ,WAAF,EAAeC,UAAf,KAClC,UAAWC,QAAX,EAAmC;AAAA,oCAAXW,QAAW;AAAXA,IAAAA,QAAW;AAAA;;AAClC,QAAMV,GAAG,GAAGD,QAAQ,CAAED,UAAF,CAApB;AACA,QAAMG,KAAK,GAAGD,GAAG,CAACE,IAAJ,CAASD,KAAvB;AACA,QAAME,IAAI,GAAGF,KAAK,CAACU,IAAN,CAAcC,OAAF,IACxB,KAAKC,MAAL,CAAaD,OAAb,EAAsBF,QAAtB,CADY,CAAb;AAGA,QAAML,OAAO,GAAGF,IAAI,GACjB,MACAX,WAAW,CAAG,OAAOK,WAAa,EAAvB,EAA0BG,GAAG,CAACM,WAAJ,EAA1B,CAAX,GACA,MADA,GAEA,iDAFA,GAGAb,aAAa,CAAEiB,QAAF,CALI,GAMjB,MACAlB,WAAW,CAAEK,WAAF,EAAeG,GAAG,CAACM,WAAJ,EAAf,CAAX,GACA,MADA,GAEA,6CAFA,GAGAb,aAAa,CAAEiB,QAAF,CAHb,GAIA,IAJA,GAKA,2BALA,GAMAT,KAAK,CAACM,GAAN,CAAWb,aAAX,CAbH;AAeAM,EAAAA,GAAG,CAACQ,gBAAJ,IAAwB,CAAxB;AAEA,SAAO;AACNH,IAAAA,OADM;AAENF,IAAAA;AAFM,GAAP;AAIA,CA5BF;;AA8BAW,MAAM,CAACC,MAAP,CACCC,MAAM,CAACC,OAAP,CAAgBtB,iBAAhB,EAAoCuB,MAApC,CACC,CAAEC,MAAF,WAA2C;AAAA,MAAjC,CAAErB,UAAF,EAAcD,WAAd,CAAiC;AAC1C,QAAMuB,eAAe,GAAI,GAAGvB,WAAa,MAAzC;AAEA,SAAO,EACN,GAAGsB,MADG;AAEN,KAAEtB,WAAF,GAAiBD,6BAA6B,CAC5C,IAAIC,WAAa,EAD2B,EAE7CC,UAF6C,CAFxC;AAMN,KAAEsB,eAAF,GAAqBX,0BAA0B,CAC7C,IAAIW,eAAiB,EADwB,EAE9CtB,UAF8C;AANzC,GAAP;AAWA,CAfF,EAgBC,EAhBD,CADD","sourcesContent":["/**\n * External dependencies\n */\nimport { matcherHint, printExpected, printReceived } from 'jest-matcher-utils';\n\n/**\n * Internal dependencies\n */\nimport supportedMatchers from './supported-matchers';\n\nconst createToHaveBeenCalledMatcher =\n\t( matcherName, methodName ) => ( received ) => {\n\t\tconst spy = received[ methodName ];\n\t\tconst calls = spy.mock.calls;\n\t\tconst pass = calls.length > 0;\n\t\tconst message = pass\n\t\t\t? () =>\n\t\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function not to be called but it was called with:\\n' +\n\t\t\t\t\tcalls.map( printReceived )\n\t\t\t: () =>\n\t\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function to be called.';\n\n\t\tspy.assertionsNumber += 1;\n\n\t\treturn {\n\t\t\tmessage,\n\t\t\tpass,\n\t\t};\n\t};\n\nconst createToHaveBeenCalledWith = ( matcherName, methodName ) =>\n\tfunction ( received, ...expected ) {\n\t\tconst spy = received[ methodName ];\n\t\tconst calls = spy.mock.calls;\n\t\tconst pass = calls.some( ( objects ) =>\n\t\t\tthis.equals( objects, expected )\n\t\t);\n\t\tconst message = pass\n\t\t\t? () =>\n\t\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function not to be called with:\\n' +\n\t\t\t\t\tprintExpected( expected )\n\t\t\t: () =>\n\t\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t\t'\\n\\n' +\n\t\t\t\t\t'Expected mock function to be called with:\\n' +\n\t\t\t\t\tprintExpected( expected ) +\n\t\t\t\t\t'\\n' +\n\t\t\t\t\t'but it was called with:\\n' +\n\t\t\t\t\tcalls.map( printReceived );\n\n\t\tspy.assertionsNumber += 1;\n\n\t\treturn {\n\t\t\tmessage,\n\t\t\tpass,\n\t\t};\n\t};\n\nexpect.extend(\n\tObject.entries( supportedMatchers ).reduce(\n\t\t( result, [ methodName, matcherName ] ) => {\n\t\t\tconst matcherNameWith = `${ matcherName }With`;\n\n\t\t\treturn {\n\t\t\t\t...result,\n\t\t\t\t[ matcherName ]: createToHaveBeenCalledMatcher(\n\t\t\t\t\t`.${ matcherName }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t\t[ matcherNameWith ]: createToHaveBeenCalledWith(\n\t\t\t\t\t`.${ matcherNameWith }`,\n\t\t\t\t\tmethodName\n\t\t\t\t),\n\t\t\t};\n\t\t},\n\t\t{}\n\t)\n);\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/jest-console",
3
- "version": "5.3.0",
3
+ "version": "6.0.1-next.957ca95e4c.0",
4
4
  "description": "Custom Jest matchers for the Console object.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -21,7 +21,7 @@
21
21
  "url": "https://github.com/WordPress/gutenberg/issues"
22
22
  },
23
23
  "engines": {
24
- "node": ">=12"
24
+ "node": ">=14"
25
25
  },
26
26
  "files": [
27
27
  "build",
@@ -33,8 +33,7 @@
33
33
  "types": "types",
34
34
  "dependencies": {
35
35
  "@babel/runtime": "^7.16.0",
36
- "jest-matcher-utils": "^27.4.2",
37
- "lodash": "^4.17.21"
36
+ "jest-matcher-utils": "^27.4.2"
38
37
  },
39
38
  "peerDependencies": {
40
39
  "jest": ">=27"
@@ -42,5 +41,5 @@
42
41
  "publishConfig": {
43
42
  "access": "public"
44
43
  },
45
- "gitHead": "48d5f37dfb52d2e77c8eeb662f9874cf141b8c6b"
44
+ "gitHead": "272a74bbbaab10ee24424eafe9578e705fbfbbb4"
46
45
  }