Skip to content

Commit

Permalink
test(component-my-circle): use the new method for test
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebastian Schürmann committed Dec 28, 2024
1 parent 13808aa commit 82b2442
Showing 1 changed file with 2 additions and 13 deletions.
15 changes: 2 additions & 13 deletions packages/component-my-circle/test/component.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,30 +2,19 @@ import { describe, it, beforeEach, afterEach } from 'node:test';
import assert from 'node:assert';
import { resolve, dirname } from 'path';
import { fileURLToPath } from 'url';
import { TestHelper, MountContext, Compiler, VirtualCompilerHost } from 'vanillin';
import { TestHelper, MountContext } from 'vanillin';

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const componentPath = resolve(__dirname, '../src/my-circle.ts');
const expectedOutputPath = resolve(__dirname, '../dist/my-circle.js');

describe('MyCircle Component', () => {
let mountContext: MountContext;
let host: VirtualCompilerHost

beforeEach(async () => {
// use the compiler
// with memfs
const compiler = await Compiler.withVirtualFs([componentPath], Compiler.DEFAULT_COMPILER_OPTIONS);
// compile the component (.emit)
await compiler.emit();
host = (compiler).host as VirtualCompilerHost;

// extract the files from the compiler result
const helper = new TestHelper();
const componentCode = host.volume.readFileSync(expectedOutputPath, 'utf8').toString();
mountContext = await helper.mountAsScript('my-circle', componentCode);
mountContext = await helper.compileAndMountAsScript('my-circle', componentPath);
});

afterEach(() => {
Expand Down

0 comments on commit 82b2442

Please sign in to comment.