jest-svelte-events
Advanced tools
Comparing version 1.0.4 to 1.0.5
@@ -5,2 +5,9 @@ # Changelog | ||
### [1.0.5](https://github.com/mihar-22/jest-svelte-events/compare/v1.0.4...v1.0.5) (2019-12-12) | ||
### Bug Fixes | ||
* use jest equality check over underscore ([39a91ba](https://github.com/mihar-22/jest-svelte-events/commit/39a91ba1a25b948955b68fcaaada6349f64bda28)) | ||
### [1.0.4](https://github.com/mihar-22/jest-svelte-events/compare/v1.0.3...v1.0.4) (2019-12-12) | ||
@@ -7,0 +14,0 @@ |
@@ -1,2 +0,2 @@ | ||
var e=require("underscore");let t,n;beforeEach(()=>{t={},n=[]}),afterEach(()=>{n.forEach(e=>e())});const s=(e,i)=>{if(Array.isArray(i))return void i.forEach(t=>s(e,t));if(t[e]||(t[e]={},t[e].stack=[]),t[e][i])return;t[e][i]={payloads:[],calls:0};const o=e.$on(i,n=>{t[e].stack.push(i),t[e][i].payloads.push(n.detail),t[e][i].calls+=1});n.push(o)},i=e=>{const n=t[e];if(!n)throw Error("This component has not been registered and has no listeners, setup the listener before calling the matcher.\n\nEg: listen(component, 'myEvent')\n\n");return n},o=(e,t)=>{const n=i(e)[t];if(!n)throw Error(`There are no listeners for the event \`${t}\` on this component, `+"setup the listener before calling the matcher.\n\nEg: listen(component, 'myEvent')\n\n");return n},a=e=>`time${1===e?"":"s"}`;function r(t,n,s,a,r,c=!1){const{matcherHint:l,printExpected:d,printReceived:v}=this.utils,h=n.isNot,p=i(s),u=o(p,a),E=u.payloads.some(t=>e.isEqual(t,r)),m=l(t,"component",void 0,n),$=1===u.payloads.length?`${v(u.payloads[0])}`:u.payloads.map((e,t)=>`\n\t ${t}: ${v(e)}`),f=(c&&u.calls>1||u.calls>0&&!h?`\nReceived: ${$}`:"")+"\n\n"+`Event: ${a}\n`+`Number of calls: ${v(u.calls)}\n`+`Events stack: ${v(p.stack)}`;return{pass:E,message:(e=>()=>m+"\n\n"+(e=>`Expected${e?" not to have fired with":""}: ${d(r)}`)(e)+f)(!!E),actual:a}}var c={toHaveFiredEvent:function(e,t){const{matcherHint:n,printExpected:s,printReceived:a}=this.utils,r=i(e),c=o(r,t).calls>0,l=n("toHaveFiredEvent","component",void 0,{isNot:this.isNot}),d=`Recevied events: ${a(r.stack)}`;return{pass:c,message:(e=>()=>l+"\n\n"+(e=>`Expected${e?" not ":" "}to have fired: ${s(t)}\n`)(e)+d)(!!c),actual:t}},toHaveFiredEvents:function(e,t){const{matcherHint:n,printExpected:s,printReceived:o}=this.utils,a=i(e),r=t[this.isNot?"some":"every"](e=>a.stack.includes(e)),c=n("toHaveFiredEvents","component",void 0,{isNot:this.isNot}),l=`Recevied events: ${o(a.stack)}`;return{pass:r,message:(e=>()=>c+"\n\n"+(e=>`Expected${e?" not ":" "}to have fired: ${s(t)}\n`)(e)+l)(!!r),actual:t}},toHaveFiredEventsInOrder:function(t,n){const{matcherHint:s,printExpected:o,printReceived:a}=this.utils,r=i(t),c=e.isEqual(r.stack,n),l=s("toHaveFiredEventsInOrder","component",void 0,{isNot:this.isNot}),d=`Recevied events in order: ${a(r.stack)}`;return{pass:c,message:(e=>()=>l+"\n\n"+(e=>`Expected${e?" not ":" "}to have fired in order: ${o(n)}\n`)(e)+d)(!!c),actual:n}},toHaveFiredEventTimes:function(e,t,n){const{matcherHint:s,printExpected:r,printReceived:c}=this.utils,l=i(e),d=o(l,t),v=d.calls===n,h=s("toHaveFiredEventTimes","component",void 0,{isNot:this.isNot}),p=`Recevied: ${c(d.calls)} ${a(d.calls)}\n\n`+`Events stack: ${c(l.stack)}`;return{pass:v,message:(e=>()=>h+"\n\n"+(e=>`Expected${e?" not ":" "}to have fired ${t}: ${r(n)} ${a(n)}\n`)(e)+p)(!!v),actual:t}},toHaveFiredEventWith:function(e,t,n){return r.call(this,"toHaveFiredEventWith",{isNot:this.isNot},e,t,n)},toHaveFiredLastEventWith:function(e,t){const{printExpected:n,printReceived:s}=this.utils,o=i(e),a=o.stack[o.stack.length-1];return null==a?{pass:!1,message:()=>`Expected: ${n(t)}\n`+`Received: ${s("no events")}`}:r.call(this,"toHaveFiredLastEventWith",{isNot:this.isNot},e,a,t,!0)},toHaveFiredNthEventWith:function(e,t,n){const{printExpected:s,printReceived:o}=this.utils,a=i(e).stack[t-1];return null==a?{pass:!1,message:()=>`Expected: ${s(n)}\n`+`Received: ${o("no events")}`}:r.call(this,"toHaveFiredNthEventWith",{isNot:this.isNot},e,a,n,!0)}};void 0===global.listen&&(global.listen=s),void 0!==global.expect?global.expect.extend(c):console.error("Unable to find Jest's global expect.\nPlease check you have added jest-svelte-events correctly to your Jest configuration.\nSee https://github.com/mihar-22/jest-svelte-events#installation for help."); | ||
let e,t;beforeEach(()=>{e={},t=[]}),afterEach(()=>{t.forEach(e=>e())});const n=(s,i)=>{if(Array.isArray(i))return void i.forEach(e=>n(s,e));if(e[s]||(e[s]={},e[s].stack=[]),e[s][i])return;e[s][i]={payloads:[],calls:0};const o=s.$on(i,t=>{e[s].stack.push(i),e[s][i].payloads.push(t.detail),e[s][i].calls+=1});t.push(o)},s=t=>{const n=e[t];if(!n)throw Error("This component has not been registered and has no listeners, setup the listener before calling the matcher.\n\nEg: listen(component, 'myEvent')\n\n");return n},i=(e,t)=>{const n=s(e)[t];if(!n)throw Error(`There are no listeners for the event \`${t}\` on this component, `+"setup the listener before calling the matcher.\n\nEg: listen(component, 'myEvent')\n\n");return n},o=e=>`time${1===e?"":"s"}`;function a(e,t,n,o,a,c=!1){const{matcherHint:r,printExpected:l,printReceived:d}=this.utils,v=t.isNot,h=this.equals,p=s(n),u=i(p,o),E=u.payloads.some(e=>h(e,a)),m=r(e,"component",void 0,t),$=1===u.payloads.length?`${d(u.payloads[0])}`:u.payloads.map((e,t)=>`\n\t ${t}: ${d(e)}`),f=(c&&u.calls>1||u.calls>0&&!v?`\nReceived: ${$}`:"")+"\n\n"+`Event: ${o}\n`+`Number of calls: ${d(u.calls)}\n`+`Events stack: ${d(p.stack)}`;return{pass:E,message:(e=>()=>m+"\n\n"+(e=>`Expected${e?" not to have fired with":""}: ${l(a)}`)(e)+f)(!!E),actual:o}}var c={toHaveFiredEvent:function(e,t){const{matcherHint:n,printExpected:o,printReceived:a}=this.utils,c=s(e),r=i(c,t).calls>0,l=n("toHaveFiredEvent","component",void 0,{isNot:this.isNot}),d=`Recevied events: ${a(c.stack)}`;return{pass:r,message:(e=>()=>l+"\n\n"+(e=>`Expected${e?" not ":" "}to have fired: ${o(t)}\n`)(e)+d)(!!r),actual:t}},toHaveFiredEvents:function(e,t){const{matcherHint:n,printExpected:i,printReceived:o}=this.utils,a=s(e),c=t[this.isNot?"some":"every"](e=>a.stack.includes(e)),r=n("toHaveFiredEvents","component",void 0,{isNot:this.isNot}),l=`Recevied events: ${o(a.stack)}`;return{pass:c,message:(e=>()=>r+"\n\n"+(e=>`Expected${e?" not ":" "}to have fired: ${i(t)}\n`)(e)+l)(!!c),actual:t}},toHaveFiredEventsInOrder:function(e,t){const{matcherHint:n,printExpected:i,printReceived:o}=this.utils,a=s(e),c=this.equals(a.stack,t),r=n("toHaveFiredEventsInOrder","component",void 0,{isNot:this.isNot}),l=`Recevied events in order: ${o(a.stack)}`;return{pass:c,message:(e=>()=>r+"\n\n"+(e=>`Expected${e?" not ":" "}to have fired in order: ${i(t)}\n`)(e)+l)(!!c),actual:t}},toHaveFiredEventTimes:function(e,t,n){const{matcherHint:a,printExpected:c,printReceived:r}=this.utils,l=s(e),d=i(l,t),v=d.calls===n,h=a("toHaveFiredEventTimes","component",void 0,{isNot:this.isNot}),p=`Recevied: ${r(d.calls)} ${o(d.calls)}\n\n`+`Events stack: ${r(l.stack)}`;return{pass:v,message:(e=>()=>h+"\n\n"+(e=>`Expected${e?" not ":" "}to have fired ${t}: ${c(n)} ${o(n)}\n`)(e)+p)(!!v),actual:t}},toHaveFiredEventWith:function(e,t,n){return a.call(this,"toHaveFiredEventWith",{isNot:this.isNot},e,t,n)},toHaveFiredLastEventWith:function(e,t){const{printExpected:n,printReceived:i}=this.utils,o=s(e),c=o.stack[o.stack.length-1];return null==c?{pass:!1,message:()=>`Expected: ${n(t)}\n`+`Received: ${i("no events")}`}:a.call(this,"toHaveFiredLastEventWith",{isNot:this.isNot},e,c,t,!0)},toHaveFiredNthEventWith:function(e,t,n){const{printExpected:i,printReceived:o}=this.utils,c=s(e).stack[t-1];return null==c?{pass:!1,message:()=>`Expected: ${i(n)}\n`+`Received: ${o("no events")}`}:a.call(this,"toHaveFiredNthEventWith",{isNot:this.isNot},e,c,n,!0)}};void 0===global.listen&&(global.listen=n),void 0!==global.expect?global.expect.extend(c):console.error("Unable to find Jest's global expect.\nPlease check you have added jest-svelte-events correctly to your Jest configuration.\nSee https://github.com/mihar-22/jest-svelte-events#installation for help."); | ||
//# sourceMappingURL=index.js.map |
{ | ||
"name": "jest-svelte-events", | ||
"version": "1.0.4", | ||
"version": "1.0.5", | ||
"description": "Custom Jest matchers to test Svelte events", | ||
@@ -50,5 +50,3 @@ "main": "dist/index.js", | ||
}, | ||
"dependencies": { | ||
"underscore": "^1.9.1" | ||
}, | ||
"dependencies": {}, | ||
"devDependencies": { | ||
@@ -55,0 +53,0 @@ "@babel/core": "^7.7.5", |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Minified code
QualityThis package contains minified code. This may be harmless in some cases where minified code is included in packaged libraries, however packages on npm should not minify code.
Found 1 instance in 1 package
28530
1
0
0
- Removedunderscore@^1.9.1
- Removedunderscore@1.13.7(transitive)