forked from ayoreis/import
-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.ts
38 lines (31 loc) · 877 Bytes
/
test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { dynamicImport, importString } from './mod.ts';
Deno.test('`importModule`', async () => {
console.log(await dynamicImport('test', { force: true }));
console.log(
await dynamicImport(
'https://api.observablehq.com/d/6388e91a5ea79803.js?v=3',
{
force: true,
},
),
);
});
Deno.test('importString', async () => {
console.log(await importString('export const foo = \'bar\''));
});
Deno.test('importString with modules', async () => {
const { default: renderer } = await importString(
`export default async function () {
const { render } = await dynamicImport('https://deno.land/x/mustache_ts@v0.4.1.1/mustache.ts');
const template = '{{foo}}, {{bar}}!'
const view = {
foo: 'Hello',
bar: 'World!'
}
const output = render(template, view)
return output;
};`,
{ parameters: { dynamicImport } },
);
console.log(await renderer());
});