From 656daa851708484a69e3fa9f1fbe608cb07b8f68 Mon Sep 17 00:00:00 2001 From: overlookmotel Date: Sat, 16 Dec 2023 13:54:18 +0000 Subject: [PATCH] Tests: More tests for internal vars in instrumentation [improve] --- test/misc.test.js | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/test/misc.test.js b/test/misc.test.js index 5940c0bb..5db845b5 100644 --- a/test/misc.test.js +++ b/test/misc.test.js @@ -25,6 +25,20 @@ describe('Internal vars created by instrumentation do not interfere with code', } }); + itSerializes('`getScopeId`', { + in: ` + 'use strict'; + module.exports = () => typeof livepack_getScopeId; + `, + out: '()=>typeof livepack_getScopeId', + validate(fn, {transpiled}) { + expect(fn()).toBe('undefined'); + + // Check the temp var name which instrumentation creates matches the one being tested for + expect(transpiled).toInclude('const [livepack1_tracker, livepack1_getScopeId] = require('); + } + }); + itSerializes('`scopeId`', { in: ` 'use strict'; @@ -74,4 +88,18 @@ describe('Internal vars created by instrumentation do not interfere with code', expect(transpiled).toInclude('Object.setPrototypeOf(livepack1_temp_6 ='); } }); + + itSerializes('`getFnInfo`', { + in: ` + 'use strict'; + module.exports = () => typeof livepack_getFnInfo_3; + `, + out: '()=>typeof livepack_getFnInfo_3', + validate(fn, {transpiled}) { + expect(fn()).toBe('undefined'); + + // Check the temp var name which instrumentation creates matches the one being tested for + expect(transpiled).toInclude('function livepack1_getFnInfo_3() {'); + } + }); });