Page MenuHomeSealhub

compiling.test.ts
No OneTemporary

Authored By
Unknown
Size
2 KB
Referenced Files
None
Subscribers
None

compiling.test.ts

import { compile, tempstream_esbuild } from "src/tempstream_esbuild.js";
import fs from "node:fs";
describe("Example", () => {
describe("example", () => {
it("simple assignment, skipping whitespace", async () => {
let output = compile(
`var a =
<hello></hello>`,
"example.tsx"
);
let supposed = `import {tempstream as tmpstream_opt, JSX as tmpjsx} from 'tempstream'
var a =
tmpstream_opt\`<hello></hello>\``;
if (!output.startsWith(supposed)) throw Error("Eq failed");
});
it("simple assignment, skipping more whitespace", async () => {
let output = compile(
`var a =
<hello></hello>`,
"example.tsx"
);
let supposed = `import {tempstream as tmpstream_opt, JSX as tmpjsx} from 'tempstream'
var a =
tmpstream_opt\`<hello></hello>\``;
if (!output.startsWith(supposed)) throw Error("Eq failed");
});
it("removing comments", async () => {
let output = compile(
`var a =
<hello>{ /*
Hello world
*/
/*
* Foo bar baz
*/
}</hello>`,
"example.tsx"
);
let supposed = `import {tempstream as tmpstream_opt, JSX as tmpjsx} from 'tempstream'
var a =
tmpstream_opt\`<hello></hello>\``;
if (!output.startsWith(supposed)) throw Error("Eq failed");
});
it("removing fragments and comments", async () => {
let output = compile(
`var a =
<><hello>{ /*
Hello world
*/
/*
* Foo bar baz
*/
}</hello></>`,
"example.tsx"
);
let supposed = `import {tempstream as tmpstream_opt, JSX as tmpjsx} from 'tempstream'
var a =
tmpstream_opt\`<hello></hello>\``;
if (!output.startsWith(supposed)) throw Error("Eq failed");
});
it("Everything together, all at once", async () => {
let output = compile(
`var a =
<><hello>{ /*
Hello world
*/
/*
* Foo bar baz
*/
}
{() => {
let a = <><div></div></>
let b = <div> {a} </div>
}()
}
</hello></>`,
"example.tsx"
);
let supposed = `import {tempstream as tmpstream_opt, JSX as tmpjsx} from 'tempstream'
var a =
tmpstream_opt\`<hello>
\${() => {
let a = tmpstream_opt\`<div></div>\`
let b = tmpstream_opt\`<div> \${a} </div>\`
}()
}
</hello>\``;
if (!output.startsWith(supposed)) throw Error("Eq failed");
});
});
});

File Metadata

Mime Type
application/javascript
Expires
Fri, Nov 27, 19:25 (8 h, 17 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
1213565
Default Alt Text
compiling.test.ts (2 KB)

Event Timeline