diff --git a/examples/blog-multiple-authors/src/components/MainHead.astro b/examples/blog-multiple-authors/src/components/MainHead.astro index 9e0f6f8d5..c780d24c3 100644 --- a/examples/blog-multiple-authors/src/components/MainHead.astro +++ b/examples/blog-multiple-authors/src/components/MainHead.astro @@ -18,7 +18,7 @@ const { title, description, image, type, next, prev, canonicalURL } = Astro.prop - + diff --git a/packages/astro/package.json b/packages/astro/package.json index de7133b15..296b0f151 100644 --- a/packages/astro/package.json +++ b/packages/astro/package.json @@ -53,7 +53,7 @@ "test": "mocha --parallel --timeout 15000" }, "dependencies": { - "@astrojs/compiler": "^0.2.3", + "@astrojs/compiler": "^0.2.8", "@astrojs/language-server": "^0.7.16", "@astrojs/markdown-remark": "^0.3.1", "@astrojs/markdown-support": "0.3.1", diff --git a/packages/astro/test/astro-attrs.test.js b/packages/astro/test/astro-attrs.test.js index 29b31d8c6..81b1fc716 100644 --- a/packages/astro/test/astro-attrs.test.js +++ b/packages/astro/test/astro-attrs.test.js @@ -2,14 +2,14 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ projectRoot: './fixtures/astro-attrs/' }); - await fixture.build(); -}); - describe('Attributes', async () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ projectRoot: './fixtures/astro-attrs/' }); + await fixture.build(); + }); + it('Passes attributes to elements as expected', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/astro-children.test.js b/packages/astro/test/astro-children.test.js index 840c3422e..3017307aa 100644 --- a/packages/astro/test/astro-children.test.js +++ b/packages/astro/test/astro-children.test.js @@ -2,17 +2,17 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ - projectRoot: './fixtures/astro-children/', - renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-vue', '@astrojs/renderer-svelte'], - }); - await fixture.build(); -}); - describe('Component children', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ + projectRoot: './fixtures/astro-children/', + renderers: ['@astrojs/renderer-preact', '@astrojs/renderer-vue', '@astrojs/renderer-svelte'], + }); + await fixture.build(); + }); + it('Passes string children to framework components', async () => { const html = await fixture.readFile('/strings/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/astro-dynamic.test.js b/packages/astro/test/astro-dynamic.test.js index 2cc89f97f..78f35a45d 100644 --- a/packages/astro/test/astro-dynamic.test.js +++ b/packages/astro/test/astro-dynamic.test.js @@ -2,14 +2,14 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ projectRoot: './fixtures/astro-dynamic/' }); - await fixture.build(); -}); - describe('Dynamic components', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ projectRoot: './fixtures/astro-dynamic/' }); + await fixture.build(); + }); + it('Loads packages that only run code in client', async () => { const html = await fixture.readFile('/index.html'); diff --git a/packages/astro/test/astro-expr.test.js b/packages/astro/test/astro-expr.test.js index 2e97e6352..f10040586 100644 --- a/packages/astro/test/astro-expr.test.js +++ b/packages/astro/test/astro-expr.test.js @@ -2,17 +2,17 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ - projectRoot: './fixtures/astro-expr/', - renderers: ['@astrojs/renderer-preact'], - }); - await fixture.build(); -}); - describe('Expressions', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ + projectRoot: './fixtures/astro-expr/', + renderers: ['@astrojs/renderer-preact'], + }); + await fixture.build(); + }); + it('Can load page', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/astro-fallback.test.js b/packages/astro/test/astro-fallback.test.js index 3446c8d44..515f3c854 100644 --- a/packages/astro/test/astro-fallback.test.js +++ b/packages/astro/test/astro-fallback.test.js @@ -2,17 +2,17 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ - projectRoot: './fixtures/astro-fallback', - renderers: ['@astrojs/renderer-preact'], - }); - await fixture.build(); -}); - describe('Dynamic component fallback', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ + projectRoot: './fixtures/astro-fallback', + renderers: ['@astrojs/renderer-preact'], + }); + await fixture.build(); + }); + it('Shows static content', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/astro-get-static-paths.test.js b/packages/astro/test/astro-get-static-paths.test.js index 88add6234..66091d562 100644 --- a/packages/astro/test/astro-get-static-paths.test.js +++ b/packages/astro/test/astro-get-static-paths.test.js @@ -1,20 +1,20 @@ import { expect } from 'chai'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ - projectRoot: './fixtures/astro-get-static-paths/', - buildOptions: { - site: 'https://mysite.dev/blog/', - sitemap: false, - }, - }); - await fixture.build(); -}); - describe('getStaticPaths()', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ + projectRoot: './fixtures/astro-get-static-paths/', + buildOptions: { + site: 'https://mysite.dev/blog/', + sitemap: false, + }, + }); + await fixture.build(); + }); + it('is only called once during build', () => { // useless expect; if build() throws in setup then this test fails expect(true).to.equal(true); diff --git a/packages/astro/test/astro-global.test.js b/packages/astro/test/astro-global.test.js index 9f100c699..ad002b985 100644 --- a/packages/astro/test/astro-global.test.js +++ b/packages/astro/test/astro-global.test.js @@ -2,20 +2,20 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ - projectRoot: './fixtures/astro-global/', - buildOptions: { - site: 'https://mysite.dev/blog/', - sitemap: false, - }, - }); - await fixture.build(); -}); - describe('Astro.*', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ + projectRoot: './fixtures/astro-global/', + buildOptions: { + site: 'https://mysite.dev/blog/', + sitemap: false, + }, + }); + await fixture.build(); + }); + it('Astro.request.url', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/astro-pageDirectoryUrl.test.js b/packages/astro/test/astro-pageDirectoryUrl.test.js index a7179c40d..e741b39a9 100644 --- a/packages/astro/test/astro-pageDirectoryUrl.test.js +++ b/packages/astro/test/astro-pageDirectoryUrl.test.js @@ -1,19 +1,19 @@ import { expect } from 'chai'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ - projectRoot: './fixtures/astro-page-directory-url', - buildOptions: { - pageUrlFormat: 'file', - }, - }); - await fixture.build(); -}); - describe('pageUrlFormat', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ + projectRoot: './fixtures/astro-page-directory-url', + buildOptions: { + pageUrlFormat: 'file', + }, + }); + await fixture.build(); + }); + it('outputs', async () => { expect(await fixture.readFile('/client/index.html')).to.be.ok; expect(await fixture.readFile('/nested-md/index.html')).to.be.ok; diff --git a/packages/astro/test/astro-pages.test.js b/packages/astro/test/astro-pages.test.js index 2161800a6..8637ac0f3 100644 --- a/packages/astro/test/astro-pages.test.js +++ b/packages/astro/test/astro-pages.test.js @@ -2,14 +2,14 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ projectRoot: './fixtures/astro-pages/' }); - await fixture.build(); -}); - describe('Pages', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ projectRoot: './fixtures/astro-pages/' }); + await fixture.build(); + }); + it('Can find page with "index" at the end file name', async () => { const html = await fixture.readFile('/posts/name-with-index/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/astro-public.test.js b/packages/astro/test/astro-public.test.js index 7794e3b97..6f7695ccd 100644 --- a/packages/astro/test/astro-public.test.js +++ b/packages/astro/test/astro-public.test.js @@ -1,14 +1,14 @@ import { expect } from 'chai'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ projectRoot: './fixtures/astro-public/' }); - await fixture.build(); -}); - describe('Public', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ projectRoot: './fixtures/astro-public/' }); + await fixture.build(); + }); + it('css and js files do not get bundled', async () => { let indexHtml = await fixture.readFile('/index.html'); expect(indexHtml).to.include(''); diff --git a/packages/astro/test/astro-sitemap-rss.test.js b/packages/astro/test/astro-sitemap-rss.test.js index 55634c4f1..f8736ee10 100644 --- a/packages/astro/test/astro-sitemap-rss.test.js +++ b/packages/astro/test/astro-sitemap-rss.test.js @@ -1,34 +1,36 @@ import { expect } from 'chai'; import { loadFixture } from './test-utils.js'; -let fixture; +describe('Sitemaps', () => { + let fixture; -before(async () => { - fixture = await loadFixture({ - projectRoot: './fixtures/astro-sitemap-rss/', - buildOptions: { - site: 'https://astro.build/', - sitemap: true, - }, + before(async () => { + fixture = await loadFixture({ + projectRoot: './fixtures/astro-sitemap-rss/', + buildOptions: { + site: 'https://astro.build/', + sitemap: true, + }, + }); + await fixture.build(); }); - await fixture.build(); -}); -describe('RSS Generation', () => { - it('generates RSS correctly', async () => { - const rss = await fixture.readFile('/custom/feed.xml'); - expect(rss).to.equal( - `<![CDATA[MF Doomcast]]>https://astro.build/custom/feed.xmlen-usMF Doom<![CDATA[Rap Snitch Knishes (feat. Mr. Fantastik)]]>https://astro.build/episode/rap-snitch-knishes/Tue, 16 Nov 2004 00:00:00 GMTmusic172true<![CDATA[Fazers]]>https://astro.build/episode/fazers/Thu, 03 Jul 2003 00:00:00 GMTmusic197true<![CDATA[Rhymes Like Dimes (feat. Cucumber Slice)]]>https://astro.build/episode/rhymes-like-dimes/ { + it('generates RSS correctly', async () => { + const rss = await fixture.readFile('/custom/feed.xml'); + expect(rss).to.equal( + `<![CDATA[MF Doomcast]]>https://astro.build/custom/feed.xmlen-usMF Doom<![CDATA[Rap Snitch Knishes (feat. Mr. Fantastik)]]>https://astro.build/episode/rap-snitch-knishes/Tue, 16 Nov 2004 00:00:00 GMTmusic172true<![CDATA[Fazers]]>https://astro.build/episode/fazers/Thu, 03 Jul 2003 00:00:00 GMTmusic197true<![CDATA[Rhymes Like Dimes (feat. Cucumber Slice)]]>https://astro.build/episode/rhymes-like-dimes/Tue, 19 Oct 1999 00:00:00 GMTmusic259true` - ); + ); + }); }); -}); - -describe('Sitemap Generation', () => { - it('Generates Sitemap correctly', async () => { - let sitemap = await fixture.readFile('/sitemap.xml'); - expect(sitemap).to.equal( - `https://astro.build/404/index.htmlhttps://astro.build/episode/fazers/index.htmlhttps://astro.build/episode/rap-snitch-knishes/index.htmlhttps://astro.build/episode/rhymes-like-dimes/index.htmlhttps://astro.build/episodes/index.html\n` - ); + + describe('Sitemap Generation', () => { + it('Generates Sitemap correctly', async () => { + let sitemap = await fixture.readFile('/sitemap.xml'); + expect(sitemap).to.equal( + `https://astro.build/404/index.htmlhttps://astro.build/episode/fazers/index.htmlhttps://astro.build/episode/rap-snitch-knishes/index.htmlhttps://astro.build/episode/rhymes-like-dimes/index.htmlhttps://astro.build/episodes/index.html\n` + ); + }); }); }); \ No newline at end of file diff --git a/packages/astro/test/astro-slots.test.js b/packages/astro/test/astro-slots.test.js index 3b4b11c22..9401dc7f3 100644 --- a/packages/astro/test/astro-slots.test.js +++ b/packages/astro/test/astro-slots.test.js @@ -2,14 +2,14 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ projectRoot: './fixtures/astro-slots/' }); - await fixture.build(); -}); - describe('Slots', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ projectRoot: './fixtures/astro-slots/' }); + await fixture.build(); + }); + it('Basic named slots work', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/config.test.js b/packages/astro/test/config.test.js index 0ed17fc3d..b36065945 100644 --- a/packages/astro/test/config.test.js +++ b/packages/astro/test/config.test.js @@ -1,14 +1,14 @@ import { expect } from 'chai'; import { devCLI, loadFixture } from './test-utils.js'; -let hostnameFixture; -let portFixture; - -before(async () => { - [hostnameFixture, portFixture] = await Promise.all([loadFixture({ projectRoot: './fixtures/config-hostname/' }), loadFixture({ projectRoot: './fixtures/config-port/' })]); -}); - describe('config', () => { + let hostnameFixture; + let portFixture; + + before(async () => { + [hostnameFixture, portFixture] = await Promise.all([loadFixture({ projectRoot: './fixtures/config-hostname/' }), loadFixture({ projectRoot: './fixtures/config-port/' })]); + }); + describe('hostname', () => { it('can be specified in astro.config.mjs', async () => { expect(hostnameFixture.config.devOptions.hostname).to.equal('0.0.0.0'); diff --git a/packages/astro/test/custom-elements.test.js b/packages/astro/test/custom-elements.test.js index ddae47ea4..255592070 100644 --- a/packages/astro/test/custom-elements.test.js +++ b/packages/astro/test/custom-elements.test.js @@ -3,17 +3,17 @@ import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; import path from 'path'; -let fixture; - -before(async () => { - fixture = await loadFixture({ - projectRoot: './fixtures/custom-elements/', - renderers: ['@astrojs/test-custom-element-renderer'], - }); - await fixture.build(); -}); - describe('Custom Elements', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ + projectRoot: './fixtures/custom-elements/', + renderers: ['@astrojs/test-custom-element-renderer'], + }); + await fixture.build(); + }); + it('Work as constructors', async () => { const html = await fixture.readFile('/ctr/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/fetch.test.js b/packages/astro/test/fetch.test.js index 23112c479..2532b69ff 100644 --- a/packages/astro/test/fetch.test.js +++ b/packages/astro/test/fetch.test.js @@ -2,14 +2,14 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ projectRoot: './fixtures/fetch/' }); - await fixture.build(); -}); - describe('Global Fetch', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ projectRoot: './fixtures/fetch/' }); + await fixture.build(); + }); + it('Is available in Astro pages', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); diff --git a/packages/astro/test/vue-component.test.js b/packages/astro/test/vue-component.test.js index 4fbf9f12f..d76b08bd0 100644 --- a/packages/astro/test/vue-component.test.js +++ b/packages/astro/test/vue-component.test.js @@ -2,14 +2,14 @@ import { expect } from 'chai'; import cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; -let fixture; - -before(async () => { - fixture = await loadFixture({ projectRoot: './fixtures/vue-component/' }); - await fixture.build(); -}); - describe('Vue component', () => { + let fixture; + + before(async () => { + fixture = await loadFixture({ projectRoot: './fixtures/vue-component/' }); + await fixture.build(); + }); + it('Can load Vue', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); diff --git a/yarn.lock b/yarn.lock index 5bf3c159b..146b285be 100644 --- a/yarn.lock +++ b/yarn.lock @@ -106,10 +106,10 @@ "@algolia/logger-common" "4.10.5" "@algolia/requester-common" "4.10.5" -"@astrojs/compiler@^0.2.3": - version "0.2.3" - resolved "https://registry.yarnpkg.com/@astrojs/compiler/-/compiler-0.2.3.tgz#5e56444e999985f553de4a60e3838a918d4968e3" - integrity sha512-OBoiu3RxdpKPRV6ETJMWZH/EcxEtxswJA0iEqL490cMNkv9TqbOo0dc27jUVQz6CY6opIotZf+j9ajWUQJvX4g== +"@astrojs/compiler@^0.2.8": + version "0.2.8" + resolved "https://registry.yarnpkg.com/@astrojs/compiler/-/compiler-0.2.8.tgz#73ab99cfcbf5e56500a60058594decf7db9d99d0" + integrity sha512-RuvzJDhZZ5S3mPZhY0Y+4MBfTGqcs6Z9PpTviOy50Yb8GQ9wDaCqU3q95e9BH3p5j50xUpmyGMSOyuRFaFuCLw== dependencies: typescript "^4.3.5"