diff --git a/test/with.test.js b/test/with.test.js index 975c1932..aba3a50c 100644 --- a/test/with.test.js +++ b/test/with.test.js @@ -409,6 +409,40 @@ describe('with statements', () => { } }); + itSerializes('`livepack_scopeId`', { + in: ` + const x = 123; + with ({livepack_scopeId_2: 1}) { + module.exports = () => x; + } + `, + out: '(x=>a=>{with(a)return()=>x})(123)({livepack_scopeId_2:1})', + validate(fn, {transpiled}) { + expect(fn).toBeFunction(); + expect(fn()).toBe(123); + + // Check internal var matches the one being tested for + expect(transpiled.split('\n')[0]) + .toInclude(';const livepack_scopeId_2 = livepack_getScopeId();'); + } + }); + + itSerializes('`livepack_temp` for `with` object', { + in: ` + with ({livepack_temp_6: 1, x: 2}) { + module.exports = () => x; + } + `, + out: '(a=>{with(a)return()=>x})({livepack_temp_6:1,x:2})', + validate(fn, {transpiled}) { + expect(fn).toBeFunction(); + expect(fn()).toBe(2); + + // Check internal var match the one being tested for + expect(transpiled.split('\n')[0]).toInclude(';let livepack_temp_6;'); + } + }); + itSerializes('`livepack_temp` for class `super`', { in: ` class S {