import {test,expect,vi} from 'vitest';
function val(v){return typeof v==='function'?{type:'function',name:v.name,length:v.length,tag:Object.prototype.toString.call(v),mock:vi.isMockFunction(v)}:v!==null&&typeof v==='object'?{type:'object',tag:Object.prototype.toString.call(v),keys:Reflect.ownKeys(v).map(String)}:{type:typeof v,value:v}}
function shape(v){if(v===null||(typeof v!=='object'&&typeof v!=='function'))return val(v);return {type:typeof v,tag:Object.prototype.toString.call(v),nullPrototype:Object.getPrototypeOf(v)===null,objectPrototype:Object.getPrototypeOf(v)===Object.prototype,functionPrototype:Object.getPrototypeOf(v)===Function.prototype,keys:Reflect.ownKeys(v).map(k=>typeof k==='symbol'?'symbol:'+String(k.description):k),descriptors:Reflect.ownKeys(v).map(k=>{const d=Object.getOwnPropertyDescriptor(v,k);return {key:typeof k==='symbol'?'symbol:'+String(k.description):k,value:val(d.value),get:typeof d.get,set:typeof d.set,writable:d.writable??null,enumerable:d.enumerable,configurable:d.configurable}}),prototype:typeof v==='function'&&Object.hasOwn(v,'prototype')?{keys:Reflect.ownKeys(v.prototype).map(String),descriptors:Reflect.ownKeys(v.prototype).map(k=>{const d=Object.getOwnPropertyDescriptor(v.prototype,k);return {key:String(k),value:val(d.value),get:typeof d.get,set:typeof d.set,writable:d.writable??null,enumerable:d.enumerable,configurable:d.configurable}})}:null}}
function member(v,key){const d=Object.getOwnPropertyDescriptor(v,key);return d?{value:val(d.value),get:typeof d.get,set:typeof d.set,writable:d.writable??null,enumerable:d.enumerable,configurable:d.configurable}:null}
import root0 from './deleted-label.cjs';
import root1 from './hidden-label.cjs';
import root2 from './late-label.cjs';
import root3 from './deleted-method.cjs';
import root4 from './hidden-method.cjs';
import root5 from './reinserted-label.cjs';
test("complete publication deleted-label before automatic helper",async()=>{const root=root0;const before={label:member(root,'label'),method:member(root,'method'),evaluations:globalThis.__ws2MutationCounts["deleted-label"]};delete root.label;const mutation={label:member(root,'label'),method:member(root,'method'),late:member(root,'late'),evaluations:globalThis.__ws2MutationCounts["deleted-label"]};const first=await vi.importMock("./deleted-label.cjs");const second=await vi.importMock("././deleted-label.cjs");const mocked={first:shape(first),default:shape(first.default),method:shape(first.default.method),outerSame:first===second,defaultSame:first.default===second.default,methodSame:first.default.method===second.default.method,namedMethodSame:first.method===first.default.method,namedLabel:val(first.label),defaultLabel:val(first.default.label),evaluations:globalThis.__ws2MutationCounts["deleted-label"]};const result=first.default(4);const methodResult=typeof first.default.method==='function'?first.default.method():undefined;console.log('WS2_CALLABLE_MUTATION:'+JSON.stringify({name:"deleted-label",before,mutation,mocked,after:{result:val(result),methodResult:val(methodResult),calls:first.default.mock.calls,memberCalls:first.default.method?.mock?.calls??null,secondCalls:second.default.mock.calls,evaluations:globalThis.__ws2MutationCounts["deleted-label"]}}));expect(vi.isMockFunction(first.default)).toBe(true)});
test("complete publication hidden-label before automatic helper",async()=>{const root=root1;const before={label:member(root,'label'),method:member(root,'method'),evaluations:globalThis.__ws2MutationCounts["hidden-label"]};Object.defineProperty(root,'label',{enumerable:false});const mutation={label:member(root,'label'),method:member(root,'method'),late:member(root,'late'),evaluations:globalThis.__ws2MutationCounts["hidden-label"]};const first=await vi.importMock("./hidden-label.cjs");const second=await vi.importMock("././hidden-label.cjs");const mocked={first:shape(first),default:shape(first.default),method:shape(first.default.method),outerSame:first===second,defaultSame:first.default===second.default,methodSame:first.default.method===second.default.method,namedMethodSame:first.method===first.default.method,namedLabel:val(first.label),defaultLabel:val(first.default.label),evaluations:globalThis.__ws2MutationCounts["hidden-label"]};const result=first.default(4);const methodResult=typeof first.default.method==='function'?first.default.method():undefined;console.log('WS2_CALLABLE_MUTATION:'+JSON.stringify({name:"hidden-label",before,mutation,mocked,after:{result:val(result),methodResult:val(methodResult),calls:first.default.mock.calls,memberCalls:first.default.method?.mock?.calls??null,secondCalls:second.default.mock.calls,evaluations:globalThis.__ws2MutationCounts["hidden-label"]}}));expect(vi.isMockFunction(first.default)).toBe(true)});
test("complete publication late-label before automatic helper",async()=>{const root=root2;const before={label:member(root,'label'),method:member(root,'method'),evaluations:globalThis.__ws2MutationCounts["late-label"]};root.late='late';const mutation={label:member(root,'label'),method:member(root,'method'),late:member(root,'late'),evaluations:globalThis.__ws2MutationCounts["late-label"]};const first=await vi.importMock("./late-label.cjs");const second=await vi.importMock("././late-label.cjs");const mocked={first:shape(first),default:shape(first.default),method:shape(first.default.method),outerSame:first===second,defaultSame:first.default===second.default,methodSame:first.default.method===second.default.method,namedMethodSame:first.method===first.default.method,namedLabel:val(first.label),defaultLabel:val(first.default.label),evaluations:globalThis.__ws2MutationCounts["late-label"]};const result=first.default(4);const methodResult=typeof first.default.method==='function'?first.default.method():undefined;console.log('WS2_CALLABLE_MUTATION:'+JSON.stringify({name:"late-label",before,mutation,mocked,after:{result:val(result),methodResult:val(methodResult),calls:first.default.mock.calls,memberCalls:first.default.method?.mock?.calls??null,secondCalls:second.default.mock.calls,evaluations:globalThis.__ws2MutationCounts["late-label"]}}));expect(vi.isMockFunction(first.default)).toBe(true)});
test("complete publication deleted-method before automatic helper",async()=>{const root=root3;const before={label:member(root,'label'),method:member(root,'method'),evaluations:globalThis.__ws2MutationCounts["deleted-method"]};delete root.method;const mutation={label:member(root,'label'),method:member(root,'method'),late:member(root,'late'),evaluations:globalThis.__ws2MutationCounts["deleted-method"]};const first=await vi.importMock("./deleted-method.cjs");const second=await vi.importMock("././deleted-method.cjs");const mocked={first:shape(first),default:shape(first.default),method:shape(first.default.method),outerSame:first===second,defaultSame:first.default===second.default,methodSame:first.default.method===second.default.method,namedMethodSame:first.method===first.default.method,namedLabel:val(first.label),defaultLabel:val(first.default.label),evaluations:globalThis.__ws2MutationCounts["deleted-method"]};const result=first.default(4);const methodResult=typeof first.default.method==='function'?first.default.method():undefined;console.log('WS2_CALLABLE_MUTATION:'+JSON.stringify({name:"deleted-method",before,mutation,mocked,after:{result:val(result),methodResult:val(methodResult),calls:first.default.mock.calls,memberCalls:first.default.method?.mock?.calls??null,secondCalls:second.default.mock.calls,evaluations:globalThis.__ws2MutationCounts["deleted-method"]}}));expect(vi.isMockFunction(first.default)).toBe(true)});
test("complete publication hidden-method before automatic helper",async()=>{const root=root4;const before={label:member(root,'label'),method:member(root,'method'),evaluations:globalThis.__ws2MutationCounts["hidden-method"]};Object.defineProperty(root,'method',{enumerable:false});const mutation={label:member(root,'label'),method:member(root,'method'),late:member(root,'late'),evaluations:globalThis.__ws2MutationCounts["hidden-method"]};const first=await vi.importMock("./hidden-method.cjs");const second=await vi.importMock("././hidden-method.cjs");const mocked={first:shape(first),default:shape(first.default),method:shape(first.default.method),outerSame:first===second,defaultSame:first.default===second.default,methodSame:first.default.method===second.default.method,namedMethodSame:first.method===first.default.method,namedLabel:val(first.label),defaultLabel:val(first.default.label),evaluations:globalThis.__ws2MutationCounts["hidden-method"]};const result=first.default(4);const methodResult=typeof first.default.method==='function'?first.default.method():undefined;console.log('WS2_CALLABLE_MUTATION:'+JSON.stringify({name:"hidden-method",before,mutation,mocked,after:{result:val(result),methodResult:val(methodResult),calls:first.default.mock.calls,memberCalls:first.default.method?.mock?.calls??null,secondCalls:second.default.mock.calls,evaluations:globalThis.__ws2MutationCounts["hidden-method"]}}));expect(vi.isMockFunction(first.default)).toBe(true)});
test("complete publication reinserted-label before automatic helper",async()=>{const root=root5;const before={label:member(root,'label'),method:member(root,'method'),evaluations:globalThis.__ws2MutationCounts["reinserted-label"]};delete root.label;root.label='reinserted';const mutation={label:member(root,'label'),method:member(root,'method'),late:member(root,'late'),evaluations:globalThis.__ws2MutationCounts["reinserted-label"]};const first=await vi.importMock("./reinserted-label.cjs");const second=await vi.importMock("././reinserted-label.cjs");const mocked={first:shape(first),default:shape(first.default),method:shape(first.default.method),outerSame:first===second,defaultSame:first.default===second.default,methodSame:first.default.method===second.default.method,namedMethodSame:first.method===first.default.method,namedLabel:val(first.label),defaultLabel:val(first.default.label),evaluations:globalThis.__ws2MutationCounts["reinserted-label"]};const result=first.default(4);const methodResult=typeof first.default.method==='function'?first.default.method():undefined;console.log('WS2_CALLABLE_MUTATION:'+JSON.stringify({name:"reinserted-label",before,mutation,mocked,after:{result:val(result),methodResult:val(methodResult),calls:first.default.mock.calls,memberCalls:first.default.method?.mock?.calls??null,secondCalls:second.default.mock.calls,evaluations:globalThis.__ws2MutationCounts["reinserted-label"]}}));expect(vi.isMockFunction(first.default)).toBe(true)});
