Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export function validateAppBundle(
bundleBuffer: Buffer,
options: ValidationOptions = {}
) {
if (options.isIndexedRAMBundle) {
const parser = new RamBundleParser(bundleBuffer);
expect(parser.getStartupCode().length).toBeGreaterThan(0);
const [, mainModuleId] = parser
.getStartupCode()
.match(/mainModuleId: (\d+)/) || ['', '-1'];
expect(parser.getModule(parseInt(mainModuleId, 10)).length).toBeGreaterThan(
0
);
expect(
bundleBuffer.toString().includes("preloadBundleNames: [ 'base_dll' ]")
).toBe(true);
}
expect(bundleBuffer.toString()).toMatch(/this\["\w+"\] =/);
}
export function validateBaseBundle(
bundleBuffer: Buffer,
options: ValidationOptions = {}
) {
if (options.isIndexedRAMBundle) {
const parser = new RamBundleParser(bundleBuffer);
expect(parser.getStartupCode().length).toBeGreaterThan(0);
const [, mainModuleId] = parser
.getStartupCode()
.match(/mainModuleId: (\d+)/) || ['', '-1'];
expect(parser.getModule(parseInt(mainModuleId, 10)).length).toBeGreaterThan(
0
);
}
if (options.platform === 'windows') {
expect(bundleBuffer.toString().includes('react-native-windows')).toBe(true);
expect(bundleBuffer.toString().includes("OS: 'windows',")).toBe(true);
} else if (options.platform) {
expect(bundleBuffer.toString().includes('react-native')).toBe(true);
expect(bundleBuffer.toString().includes(`OS: '${options.platform}',`)).toBe(
true
);