Skip to content

Commit

Permalink
Tests: More tests for internal vars in instrumentation [improve]
Browse files Browse the repository at this point in the history
  • Loading branch information
overlookmotel committed Dec 16, 2023
1 parent ec34f49 commit 656daa8
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions test/misc.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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() {');
}
});
});

0 comments on commit 656daa8

Please sign in to comment.