chore: lint, fixes

This commit is contained in:
Nate Moore 2023-08-15 14:02:09 -05:00
parent 4912cc600b
commit 8cb00a73fa
4 changed files with 5 additions and 3 deletions

View file

@ -85,7 +85,7 @@ describe('Component children', () => {
);
// test 3: If client, and children are rendered, no template is.
expect($('#client-render').parent().children()).to.have.lengthOf(1);
expect($('#client-render').parent().children()).to.have.lengthOf(2);
expect($('#client-render').parent().find('template')).to.have.lengthOf(0);
// test 4: If client and no children are provided, no template is.

View file

@ -15,7 +15,8 @@ describe('Nested Slots', () => {
const html = await fixture.readFile('/hidden-nested/index.html');
const $ = cheerio.load(html);
expect($('script')).to.have.a.lengthOf(3, 'script rendered');
const scriptInTemplate = $($('template')[0].children[0]).find('script');
// Astro Island scripts are [async], so this will only find other types of scripts
const scriptInTemplate = $($('template')[0].children[0]).find('script:not([async])');
expect(scriptInTemplate).to.have.a.lengthOf(0, 'script defined outside of the inner template');
});

View file

@ -24,6 +24,6 @@ describe('Hydration script ordering', async () => {
// Sanity check that we're only rendering them once.
expect($('style')).to.have.a.lengthOf(1, 'hydration style added once');
expect($('script')).to.have.a.lengthOf(1, 'only one hydration script needed');
expect($('script')).to.have.a.lengthOf(4, 'only one hydration script needed');
});
});

View file

@ -253,6 +253,7 @@ export function getIslandDataFromScript(text) {
const args = { Astro, document }
// Yes, I know, `eval` is bad! But our data is embedded as JS on purpose.
// eslint-disable-next-line @typescript-eslint/no-implied-eval
return new Function(Object.keys(args), `return ${text}`)(...Object.values(args));
}