@gjsify/unit 0.3.21 → 0.4.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.
|
@@ -0,0 +1 @@
|
|
|
1
|
+
var e=Object.defineProperty,__name=(t,n)=>e(t,`name`,{value:n,configurable:!0});export{__name};
|
package/lib/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{spy as e}from"./spy.js";import"@girs/gjs";import t from"node:assert";import{quitMainLoop as n}from"@gjsify/utils/main-loop";const r=globalThis?.imports?.mainloop;let i=0,a=0,o=0,s=``,c=0,l=``,u=[],d={testTimeout:5e3,suiteTimeout:3e4,runTimeout:12e4};var TimeoutError=class extends Error{constructor(e,t){super(`Timeout: "${e}" exceeded ${t}ms`),this.name=`TimeoutError`}};async function withTimeout(e,t,n){if(t<=0)return e();let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(new TimeoutError(n,t)),t)}),a=Promise.resolve(e());a.catch(()=>{});try{return await Promise.race([a,i])}finally{clearTimeout(r)}}const configure=e=>{d={...d,...e}};function applyEnvOverrides(){try{let e=globalThis.process?.env;if(!e)return;let t=parseInt(e.GJSIFY_TEST_TIMEOUT,10);!isNaN(t)&&t>=0&&(d.testTimeout=t);let n=parseInt(e.GJSIFY_SUITE_TIMEOUT,10);!isNaN(n)&&n>=0&&(d.suiteTimeout=n);let r=parseInt(e.GJSIFY_RUN_TIMEOUT,10);!isNaN(r)&&r>=0&&(d.runTimeout=r)}catch{}}const f=`\x1B[31m`,p=`\x1B[32m`,m=`\x1B[34m`,h=`\x1B[90m`,g=`\x1B[39m`,now=()=>globalThis.performance?.now?.()??Date.now(),formatDuration=e=>e>=1e3?`${(e/1e3).toFixed(2)}s`:e>=100?`${Math.round(e)}ms`:`${e.toFixed(1)}ms`,_=typeof globalThis.process?.versions?.gjs!=`string`&&globalThis.document!==void 0?console.log:globalThis.print||console.log;var v=class MatcherFactory{actualValue;positive;not;constructor(e,t,n){this.actualValue=e,this.positive=t,n?this.not=n:this.not=new MatcherFactory(e,!t,this)}triggerResult(e,t){if(e&&!this.positive||!e&&this.positive){let e=Error(t);throw e.__testFailureCounted=!0,++a,e}}to(e){this.triggerResult(e(this.actualValue),` Expected callback to validate`)}toBe(e){this.triggerResult(this.actualValue===e,` Expected values to match using ===
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";import{spy as e}from"./spy.js";import"@girs/gjs";import t from"node:assert";import{quitMainLoop as n}from"@gjsify/utils/main-loop";const r=globalThis?.imports?.mainloop;let i=0,a=0,o=0,s=``,c=0,l=``,u=[],d={testTimeout:5e3,suiteTimeout:3e4,runTimeout:12e4};var TimeoutError=class extends Error{constructor(e,t){super(`Timeout: "${e}" exceeded ${t}ms`),this.name=`TimeoutError`}};async function withTimeout(e,t,n){if(t<=0)return e();let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(new TimeoutError(n,t)),t)}),a=Promise.resolve(e());a.catch(()=>{});try{return await Promise.race([a,i])}finally{clearTimeout(r)}}const configure=e=>{d={...d,...e}};function applyEnvOverrides(){try{let e=globalThis.process?.env;if(!e)return;let t=parseInt(e.GJSIFY_TEST_TIMEOUT,10);!isNaN(t)&&t>=0&&(d.testTimeout=t);let n=parseInt(e.GJSIFY_SUITE_TIMEOUT,10);!isNaN(n)&&n>=0&&(d.suiteTimeout=n);let r=parseInt(e.GJSIFY_RUN_TIMEOUT,10);!isNaN(r)&&r>=0&&(d.runTimeout=r)}catch{}}const f=`\x1B[31m`,p=`\x1B[32m`,m=`\x1B[34m`,h=`\x1B[90m`,g=`\x1B[39m`,now=()=>globalThis.performance?.now?.()??Date.now(),formatDuration=e=>e>=1e3?`${(e/1e3).toFixed(2)}s`:e>=100?`${Math.round(e)}ms`:`${e.toFixed(1)}ms`,_=typeof globalThis.process?.versions?.gjs!=`string`&&globalThis.document!==void 0?console.log:globalThis.print||console.log;var v=class MatcherFactory{actualValue;positive;not;constructor(e,t,n){this.actualValue=e,this.positive=t,n?this.not=n:this.not=new MatcherFactory(e,!t,this)}triggerResult(e,t){if(e&&!this.positive||!e&&this.positive){let e=Error(t);throw e.__testFailureCounted=!0,++a,e}}to(e){this.triggerResult(e(this.actualValue),` Expected callback to validate`)}toBe(e){this.triggerResult(this.actualValue===e,` Expected values to match using ===
|
|
2
2
|
Expected: ${e} (${typeof e})\n Actual: ${this.actualValue} (${typeof this.actualValue})`)}toEqual(e){this.triggerResult(this.actualValue==e,` Expected values to match using ==
|
|
3
3
|
Expected: ${e} (${typeof e})\n Actual: ${this.actualValue} (${typeof this.actualValue})`)}toStrictEqual(e){let n=!0,r=``;try{t.deepStrictEqual(this.actualValue,e)}catch(e){n=!1,r=e.message||``}this.triggerResult(n,` Expected values to be deeply strictly equal
|
|
4
4
|
Expected: ${JSON.stringify(e)}\n Actual: ${JSON.stringify(this.actualValue)}`+(r?`\n ${r}`:``))}toEqualArray(e){let t=Array.isArray(this.actualValue)&&Array.isArray(e)&&this.actualValue.length===e.length;for(let n=0;n<this.actualValue.length&&(t=this.actualValue[n]==e[n],t);n++);this.triggerResult(t,` Expected array items to match using ==
|
package/lib/esm/spy.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
function spy(t){let n=[];function spy(...e){let r;try{r=t?t.apply(this,e):void 0}catch(t){throw n.push({type:`throw`,this:this,arguments:e,throw:t}),t}return n.push({type:`return`,this:this,arguments:e,return:r}),r}return Object.defineProperties(spy,{calls:e.calls(n),returnedCalls:e.returnedCalls,thrownCalls:e.thrownCalls,firstCall:e.firstCall,lastCall:e.lastCall,firstReturnedCall:e.firstReturnedCall,lastReturnedCall:e.lastReturnedCall,firstThrownCall:e.firstThrownCall,lastThrownCall:e.lastThrownCall,reset:e.reset,toString:e.toString(t)}),spy}const e={calls(e){return{value:e,configurable:!0}},returnedCalls:{get:function(){return this.calls.filter(isReturned)},configurable:!0},thrownCalls:{get:function(){return this.calls.filter(isThrown)},configurable:!0},firstCall:{get:function(){return this.calls[0]||null},configurable:!0},lastCall:{get:function(){return this.calls[this.calls.length-1]||null},configurable:!0},firstReturnedCall:{get:function(){for(let e=0;e<this.calls.length;++e){let t=this.calls[e];if(isReturned(t))return t}return null},configurable:!0},lastReturnedCall:{get:function(){for(let e=this.calls.length-1;e>=0;--e){let t=this.calls[e];if(isReturned(t))return t}return null},configurable:!0},firstThrownCall:{get:function(){for(let e=0;e<this.calls.length;++e){let t=this.calls[e];if(isThrown(t))return t}return null},configurable:!0},lastThrownCall:{get:function(){for(let e=this.calls.length-1;e>=0;--e){let t=this.calls[e];if(isThrown(t))return t}return null},configurable:!0},reset:{value:function(){this.calls.length=0},configurable:!0},toString(e){return{value:function(){return`/* The spy of */ ${e?e.toString():`function(){}`}`},configurable:!0}}};function isReturned(e){return e.type===`return`}function isThrown(e){return e.type===`throw`}export{spy};
|
|
1
|
+
import"./_virtual/_rolldown/runtime.js";function spy(t){let n=[];function spy(...e){let r;try{r=t?t.apply(this,e):void 0}catch(t){throw n.push({type:`throw`,this:this,arguments:e,throw:t}),t}return n.push({type:`return`,this:this,arguments:e,return:r}),r}return Object.defineProperties(spy,{calls:e.calls(n),returnedCalls:e.returnedCalls,thrownCalls:e.thrownCalls,firstCall:e.firstCall,lastCall:e.lastCall,firstReturnedCall:e.firstReturnedCall,lastReturnedCall:e.lastReturnedCall,firstThrownCall:e.firstThrownCall,lastThrownCall:e.lastThrownCall,reset:e.reset,toString:e.toString(t)}),spy}const e={calls(e){return{value:e,configurable:!0}},returnedCalls:{get:function returnedCalls(){return this.calls.filter(isReturned)},configurable:!0},thrownCalls:{get:function thrownCalls(){return this.calls.filter(isThrown)},configurable:!0},firstCall:{get:function firstCall(){return this.calls[0]||null},configurable:!0},lastCall:{get:function lastCall(){return this.calls[this.calls.length-1]||null},configurable:!0},firstReturnedCall:{get:function firstReturnedCall(){for(let e=0;e<this.calls.length;++e){let t=this.calls[e];if(isReturned(t))return t}return null},configurable:!0},lastReturnedCall:{get:function lastReturnedCall(){for(let e=this.calls.length-1;e>=0;--e){let t=this.calls[e];if(isReturned(t))return t}return null},configurable:!0},firstThrownCall:{get:function firstThrownCall(){for(let e=0;e<this.calls.length;++e){let t=this.calls[e];if(isThrown(t))return t}return null},configurable:!0},lastThrownCall:{get:function lastThrownCall(){for(let e=this.calls.length-1;e>=0;--e){let t=this.calls[e];if(isThrown(t))return t}return null},configurable:!0},reset:{value:function reset(){this.calls.length=0},configurable:!0},toString(e){return{value:function toString(){return`/* The spy of */ ${e?e.toString():`function(){}`}`},configurable:!0}}};function isReturned(e){return e.type===`return`}function isThrown(e){return e.type===`throw`}export{spy};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@gjsify/unit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.0",
|
|
4
4
|
"description": "A BDD-style testing framework for Gjs",
|
|
5
5
|
"module": "lib/esm/index.js",
|
|
6
6
|
"types": "lib/types/index.d.ts",
|
|
@@ -41,15 +41,15 @@
|
|
|
41
41
|
},
|
|
42
42
|
"homepage": "https://github.com/gjsify/unit#readme",
|
|
43
43
|
"devDependencies": {
|
|
44
|
-
"@girs/gjs": "4.0.0-rc.
|
|
45
|
-
"@girs/glib-2.0": "2.88.0-4.0.0-rc.
|
|
46
|
-
"@gjsify/cli": "^0.
|
|
44
|
+
"@girs/gjs": "4.0.0-rc.15",
|
|
45
|
+
"@girs/glib-2.0": "2.88.0-4.0.0-rc.15",
|
|
46
|
+
"@gjsify/cli": "^0.4.0",
|
|
47
47
|
"@types/node": "^25.6.2",
|
|
48
48
|
"typescript": "^6.0.3"
|
|
49
49
|
},
|
|
50
50
|
"dependencies": {
|
|
51
|
-
"@gjsify/assert": "^0.
|
|
52
|
-
"@gjsify/process": "^0.
|
|
53
|
-
"@gjsify/utils": "^0.
|
|
51
|
+
"@gjsify/assert": "^0.4.0",
|
|
52
|
+
"@gjsify/process": "^0.4.0",
|
|
53
|
+
"@gjsify/utils": "^0.4.0"
|
|
54
54
|
}
|
|
55
55
|
}
|