Skip to content

Commit fa18f70

Browse files
committed
fix(tests): adapt compiler tests to recent changes
1 parent b829028 commit fa18f70

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

tests/compiler.test.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,18 @@ describe('XivCompiler', () => {
4343
const mainXivFile = path.join(import.meta.dir, TEST_DIR, 'main1.xiv');
4444
await write(mainXivFile, mainXivContent);
4545

46-
const result = await compiler.compile(mainXivFile);
46+
const result = await compiler.compile(mainXivFile, './test-output.html');
4747
const $ = cheerio.load(result);
4848

4949
expect($('body').length).toBe(1);
5050
expect($('body h1').text().trim()).toBe('Hello XIV');
5151
expect($('body p').text().trim()).toBe('This is the new era.');
5252

53-
const scriptTag = $('body script').html();
54-
expect(scriptTag).not.toBeNull();
55-
expect(scriptTag).toInclude('const XIV = {'); // A known string from the runtime
53+
const scriptTag = $('body script');
54+
expect(scriptTag.length).toBe(1);
55+
const src = scriptTag.attr('src');
56+
expect(src).not.toBeNull();
57+
expect(src).toBe('dist/runtime.js');
5658
});
5759

5860
test('head content injection', async () => {
@@ -69,7 +71,7 @@ describe('XivCompiler', () => {
6971
const mainXivFile = path.join(import.meta.dir, TEST_DIR, 'main2.xiv');
7072
await write(mainXivFile, mainXivContent);
7173

72-
const result = await compiler.compile(mainXivFile);
74+
const result = await compiler.compile(mainXivFile, './test-output.html');
7375
const $ = cheerio.load(result);
7476

7577
expect($('head').length).toBe(1);
@@ -81,7 +83,7 @@ describe('XivCompiler', () => {
8183
test('file not found error', async () => {
8284
const nonExistentFile = path.join(import.meta.dir, TEST_DIR, 'nonexistent.xiv');
8385
// Using expect().toThrow() for async functions requires a slightly different syntax
84-
await expect(compiler.compile(nonExistentFile)).rejects.toThrow(CompilerError);
85-
await expect(compiler.compile(nonExistentFile)).rejects.toThrow('Error: Main XIV file not found');
86+
await expect(compiler.compile(nonExistentFile, './test-output.html')).rejects.toThrow(CompilerError);
87+
await expect(compiler.compile(nonExistentFile, './test-output.html')).rejects.toThrow('Error: Main XIV file not found');
8688
});
8789
});

0 commit comments

Comments
 (0)