Skip to content

Commit

Permalink
test: re-enable api tests
Browse files Browse the repository at this point in the history
  • Loading branch information
j4k0xb committed Dec 3, 2023
1 parent dd0e20d commit 389a091
Showing 1 changed file with 22 additions and 20 deletions.
42 changes: 22 additions & 20 deletions packages/webcrack/test/api.test.ts
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
import { describe, expect, test } from 'vitest';
import { readFile } from 'node:fs/promises';
import { join } from 'node:path';
import { describe, expect, test, vi } from 'vitest';
import { webcrack } from '../src';

// const obfuscatedSrc = await readFile(
// join(__dirname, "samples/obfuscator.io.js"),
// "utf8",
// );
// const webpackSrc = await readFile(
// join(__dirname, "samples/webpack.js"),
// "utf8",
// );
const obfuscatedSrc = await readFile(
join(__dirname, '../../deobfuscate/test/samples/obfuscator.io.js'),
'utf8',
);
const webpackSrc = await readFile(
join(__dirname, '../../unpack/test/samples/webpack.js'),
'utf8',
);

describe('options', () => {
test.skip('no deobfuscate', async () => {
// await webcrack(webpackSrc, { deobfuscate: false });
test('no deobfuscate', async () => {
await webcrack(webpackSrc, { deobfuscate: false });
});

test.skip('no unpack', async () => {
// const result = await webcrack(webpackSrc, { unpack: false });
// expect(result.bundle).toBeUndefined();
test('no unpack', async () => {
const result = await webcrack(webpackSrc, { unpack: false });
expect(result.bundle).toBeUndefined();
});

test('no jsx', async () => {
Expand All @@ -27,12 +29,12 @@ describe('options', () => {
expect(result.code).toBe('React.createElement("div", null);');
});

test.skip('custom sandbox', async () => {
// const sandbox = vi.fn((code: string) =>
// /* isolated-vm or something */ Promise.resolve(code),
// );
// await webcrack(obfuscatedSrc, { sandbox });
// expect(sandbox).toHaveBeenCalledOnce();
test('custom sandbox', async () => {
const sandbox = vi.fn((code: string) =>
/* isolated-vm or something */ Promise.resolve(code),
);
await webcrack(obfuscatedSrc, { sandbox });
expect(sandbox).toHaveBeenCalledOnce();
});

test('mangle', async () => {
Expand Down

0 comments on commit 389a091

Please sign in to comment.