cli-testing-library
Version:
Simple and complete CLI testing utilities that encourage good testing practices.
1 lines • 1.28 kB
Source Map (JSON)
{"version":3,"file":"mutation-observer.cjs","sources":["../../src/mutation-observer.ts"],"sourcesContent":["// Used for `MutationObserver`. Unsure if it's really needed, but it's worth mentioning that these are not tied to\n// specific CLI instances of `render`. This means that if there are e2e CLI tests that run in parallel, they will\n// execute far more frequently than needed.\nconst _observers = new Map();\n\n// Not perfect as a way to make \"MutationObserver\" unique IDs, but it should work\nlet mutId = 0;\n\nclass MutationObserver {\n _cb: () => void;\n _id: number;\n\n constructor(cb: () => void) {\n this._id = ++mutId;\n this._cb = cb;\n }\n\n observe() {\n _observers.set(this._id, this._cb);\n }\n\n disconnect() {\n _observers.delete(this._id);\n }\n}\n\nfunction _runObservers() {\n Array.from(_observers.values()).forEach((cb) => cb());\n}\n\nexport { _runObservers, MutationObserver };\n"],"names":[],"mappings":";;AAGA,MAAM,iCAAiB,IAAI;AAG3B,IAAI,QAAQ;AAEZ,MAAM,iBAAiB;AAAA,EAIrB,YAAY,IAAgB;AAC1B,SAAK,MAAM,EAAE;AACb,SAAK,MAAM;AAAA,EAAA;AAAA,EAGb,UAAU;AACR,eAAW,IAAI,KAAK,KAAK,KAAK,GAAG;AAAA,EAAA;AAAA,EAGnC,aAAa;AACA,eAAA,OAAO,KAAK,GAAG;AAAA,EAAA;AAE9B;AAEA,SAAS,gBAAgB;AACjB,QAAA,KAAK,WAAW,OAAO,CAAC,EAAE,QAAQ,CAAC,OAAO,IAAI;AACtD;;;"}