@wordpress/jest-console 4.0.5 → 4.1.1

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/build/index.js CHANGED
@@ -20,7 +20,7 @@ var _supportedMatchers = _interopRequireDefault(require("./supported-matchers"))
20
20
  * Sets spy on the console object's method to make it possible to fail test when method called without assertion.
21
21
  *
22
22
  * @param {string} matcherName Name of Jest matcher.
23
- * @param {string} methodName Name of console method.
23
+ * @param {string} methodName Name of console method.
24
24
  */
25
25
  const setConsoleMethodSpy = (matcherName, methodName) => {
26
26
  const spy = jest.spyOn(console, methodName).mockName(`console.${methodName}`);
@@ -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","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"]}
package/build/matchers.js CHANGED
@@ -27,7 +27,11 @@ const createToHaveBeenCalledMatcher = (matcherName, methodName) => received => {
27
27
  };
28
28
  };
29
29
 
30
- const createToHaveBeenCalledWith = (matcherName, methodName) => (received, ...expected) => {
30
+ const createToHaveBeenCalledWith = (matcherName, methodName) => function (received) {
31
+ for (var _len = arguments.length, expected = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
32
+ expected[_key - 1] = arguments[_key];
33
+ }
34
+
31
35
  const spy = received[methodName];
32
36
  const calls = spy.mock.calls;
33
37
  const pass = (0, _lodash.some)(calls, objects => (0, _lodash.isEqual)(objects, expected));
@@ -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,GAAG,CAAEC,WAAF,EAAeC,UAAf,KACrCC,QADoE,IAEhE;AACJ,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,mE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B,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 = ( matcherName, methodName ) => (\n\treceived\n) => {\n\tconst spy = received[ methodName ];\n\tconst calls = spy.mock.calls;\n\tconst pass = calls.length > 0;\n\tconst message = pass\n\t\t? () =>\n\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function not to be called but it was called with:\\n' +\n\t\t\t\tcalls.map( printReceived )\n\t\t: () =>\n\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function to be called.';\n\n\tspy.assertionsNumber += 1;\n\n\treturn {\n\t\tmessage,\n\t\tpass,\n\t};\n};\n\nconst createToHaveBeenCalledWith = ( matcherName, methodName ) => (\n\treceived,\n\t...expected\n) => {\n\tconst spy = received[ methodName ];\n\tconst calls = spy.mock.calls;\n\tconst pass = some( calls, ( objects ) => isEqual( objects, expected ) );\n\tconst message = pass\n\t\t? () =>\n\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function not to be called with:\\n' +\n\t\t\t\tprintExpected( expected )\n\t\t: () =>\n\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function to be called with:\\n' +\n\t\t\t\tprintExpected( expected ) +\n\t\t\t\t'\\n' +\n\t\t\t\t'but it was called with:\\n' +\n\t\t\t\tcalls.map( printReceived );\n\n\tspy.assertionsNumber += 1;\n\n\treturn {\n\t\tmessage,\n\t\tpass,\n\t};\n};\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","objects","expect","extend","supportedMatchers","result","matcherNameWith"],"mappings":";;;;AAGA;;AACA;;AAKA;;AATA;AACA;AACA;;AAIA;AACA;AACA;AAGA,MAAMA,6BAA6B,GAAG,CAAEC,WAAF,EAAeC,UAAf,KACrCC,QADoE,IAEhE;AACJ,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,EA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9CnB,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 = ( matcherName, methodName ) => (\n\treceived\n) => {\n\tconst spy = received[ methodName ];\n\tconst calls = spy.mock.calls;\n\tconst pass = calls.length > 0;\n\tconst message = pass\n\t\t? () =>\n\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function not to be called but it was called with:\\n' +\n\t\t\t\tcalls.map( printReceived )\n\t\t: () =>\n\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function to be called.';\n\n\tspy.assertionsNumber += 1;\n\n\treturn {\n\t\tmessage,\n\t\tpass,\n\t};\n};\n\nconst createToHaveBeenCalledWith = ( matcherName, methodName ) => (\n\treceived,\n\t...expected\n) => {\n\tconst spy = received[ methodName ];\n\tconst calls = spy.mock.calls;\n\tconst pass = some( calls, ( objects ) => isEqual( objects, expected ) );\n\tconst message = pass\n\t\t? () =>\n\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function not to be called with:\\n' +\n\t\t\t\tprintExpected( expected )\n\t\t: () =>\n\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function to be called with:\\n' +\n\t\t\t\tprintExpected( expected ) +\n\t\t\t\t'\\n' +\n\t\t\t\t'but it was called with:\\n' +\n\t\t\t\tcalls.map( printReceived );\n\n\tspy.assertionsNumber += 1;\n\n\treturn {\n\t\tmessage,\n\t\tpass,\n\t};\n};\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"]}
@@ -12,7 +12,7 @@ import supportedMatchers from './supported-matchers';
12
12
  * Sets spy on the console object's method to make it possible to fail test when method called without assertion.
13
13
  *
14
14
  * @param {string} matcherName Name of Jest matcher.
15
- * @param {string} methodName Name of console method.
15
+ * @param {string} methodName Name of console method.
16
16
  */
17
17
 
18
18
  const setConsoleMethodSpy = (matcherName, methodName) => {
@@ -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":["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"]}
@@ -21,7 +21,11 @@ const createToHaveBeenCalledMatcher = (matcherName, methodName) => received => {
21
21
  };
22
22
  };
23
23
 
24
- const createToHaveBeenCalledWith = (matcherName, methodName) => (received, ...expected) => {
24
+ const createToHaveBeenCalledWith = (matcherName, methodName) => function (received) {
25
+ for (var _len = arguments.length, expected = new Array(_len > 1 ? _len - 1 : 0), _key = 1; _key < _len; _key++) {
26
+ expected[_key - 1] = arguments[_key];
27
+ }
28
+
25
29
  const spy = received[methodName];
26
30
  const calls = spy.mock.calls;
27
31
  const pass = some(calls, objects => isEqual(objects, expected));
@@ -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,OAA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AAF,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,CA5BD;;AA8BAS,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 = ( matcherName, methodName ) => (\n\treceived\n) => {\n\tconst spy = received[ methodName ];\n\tconst calls = spy.mock.calls;\n\tconst pass = calls.length > 0;\n\tconst message = pass\n\t\t? () =>\n\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function not to be called but it was called with:\\n' +\n\t\t\t\tcalls.map( printReceived )\n\t\t: () =>\n\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function to be called.';\n\n\tspy.assertionsNumber += 1;\n\n\treturn {\n\t\tmessage,\n\t\tpass,\n\t};\n};\n\nconst createToHaveBeenCalledWith = ( matcherName, methodName ) => (\n\treceived,\n\t...expected\n) => {\n\tconst spy = received[ methodName ];\n\tconst calls = spy.mock.calls;\n\tconst pass = some( calls, ( objects ) => isEqual( objects, expected ) );\n\tconst message = pass\n\t\t? () =>\n\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function not to be called with:\\n' +\n\t\t\t\tprintExpected( expected )\n\t\t: () =>\n\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function to be called with:\\n' +\n\t\t\t\tprintExpected( expected ) +\n\t\t\t\t'\\n' +\n\t\t\t\t'but it was called with:\\n' +\n\t\t\t\tcalls.map( printReceived );\n\n\tspy.assertionsNumber += 1;\n\n\treturn {\n\t\tmessage,\n\t\tpass,\n\t};\n};\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","isEqual","reduce","some","supportedMatchers","createToHaveBeenCalledMatcher","matcherName","methodName","received","spy","calls","mock","pass","length","message","getMockName","map","assertionsNumber","createToHaveBeenCalledWith","expected","objects","expect","extend","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,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,CA5BD;;AA8BAS,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 = ( matcherName, methodName ) => (\n\treceived\n) => {\n\tconst spy = received[ methodName ];\n\tconst calls = spy.mock.calls;\n\tconst pass = calls.length > 0;\n\tconst message = pass\n\t\t? () =>\n\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function not to be called but it was called with:\\n' +\n\t\t\t\tcalls.map( printReceived )\n\t\t: () =>\n\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function to be called.';\n\n\tspy.assertionsNumber += 1;\n\n\treturn {\n\t\tmessage,\n\t\tpass,\n\t};\n};\n\nconst createToHaveBeenCalledWith = ( matcherName, methodName ) => (\n\treceived,\n\t...expected\n) => {\n\tconst spy = received[ methodName ];\n\tconst calls = spy.mock.calls;\n\tconst pass = some( calls, ( objects ) => isEqual( objects, expected ) );\n\tconst message = pass\n\t\t? () =>\n\t\t\t\tmatcherHint( `.not${ matcherName }`, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function not to be called with:\\n' +\n\t\t\t\tprintExpected( expected )\n\t\t: () =>\n\t\t\t\tmatcherHint( matcherName, spy.getMockName() ) +\n\t\t\t\t'\\n\\n' +\n\t\t\t\t'Expected mock function to be called with:\\n' +\n\t\t\t\tprintExpected( expected ) +\n\t\t\t\t'\\n' +\n\t\t\t\t'but it was called with:\\n' +\n\t\t\t\tcalls.map( printReceived );\n\n\tspy.assertionsNumber += 1;\n\n\treturn {\n\t\tmessage,\n\t\tpass,\n\t};\n};\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"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wordpress/jest-console",
3
- "version": "4.0.5",
3
+ "version": "4.1.1",
4
4
  "description": "Custom Jest matchers for the Console object.",
5
5
  "author": "The WordPress Contributors",
6
6
  "license": "GPL-2.0-or-later",
@@ -30,7 +30,7 @@
30
30
  "main": "build/index.js",
31
31
  "module": "build-module/index.js",
32
32
  "dependencies": {
33
- "@babel/runtime": "^7.13.10",
33
+ "@babel/runtime": "^7.16.0",
34
34
  "jest-matcher-utils": "^26.6.2",
35
35
  "lodash": "^4.17.21"
36
36
  },
@@ -40,5 +40,5 @@
40
40
  "publishConfig": {
41
41
  "access": "public"
42
42
  },
43
- "gitHead": "954d6776be2ee80b5975e4ced6a3d481d8a89354"
43
+ "gitHead": "9a1dd3474d937468e4cf9caf9886ad61ef0a8f50"
44
44
  }