From 4f6b0def420b010925388f0e5e15a42aa42f7b33 Mon Sep 17 00:00:00 2001 From: Emanuele Stoppa Date: Thu, 15 Feb 2024 14:11:52 +0000 Subject: [PATCH] chore: move tests that starts with i and j (#10129) * chore: move tests that starts with i and j * add missing `after` --- ...ion.test.js => image-deletion.nodetest.js} | 9 +++--- ...ort-app.test.js => import-app.nodetest.js} | 7 +++-- ....test.js => import-ts-with-js.nodetest.js} | 5 +-- ....test.js => impostor-mdx-file.nodetest.js} | 5 +-- ...ntegration-add-page-extension.nodetest.js} | 5 +-- ...s => integration-server-setup.nodetest.js} | 5 +-- .../test/{jsx.test.js => jsx.nodetest.js} | 31 ++++++++++--------- 7 files changed, 37 insertions(+), 30 deletions(-) rename packages/astro/test/{image-deletion.test.js => image-deletion.nodetest.js} (80%) rename packages/astro/test/{import-app.test.js => import-app.nodetest.js} (52%) rename packages/astro/test/{import-ts-with-js.test.js => import-ts-with-js.nodetest.js} (78%) rename packages/astro/test/{impostor-mdx-file.test.js => impostor-mdx-file.nodetest.js} (81%) rename packages/astro/test/{integration-add-page-extension.test.js => integration-add-page-extension.nodetest.js} (77%) rename packages/astro/test/{integration-server-setup.test.js => integration-server-setup.nodetest.js} (77%) rename packages/astro/test/{jsx.test.js => jsx.nodetest.js} (60%) diff --git a/packages/astro/test/image-deletion.test.js b/packages/astro/test/image-deletion.nodetest.js similarity index 80% rename from packages/astro/test/image-deletion.test.js rename to packages/astro/test/image-deletion.nodetest.js index 2c92f2cec3..d773a45b2e 100644 --- a/packages/astro/test/image-deletion.test.js +++ b/packages/astro/test/image-deletion.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, it, before } from 'node:test'; import { testImageService } from './test-image-service.js'; import { loadFixture } from './test-utils.js'; @@ -20,17 +21,17 @@ describe('astro:assets - delete images that are unused', () => { it('should delete images that are only used for optimization', async () => { const imagesOnlyOptimized = await fixture.glob('_astro/onlyone.*.*'); - expect(imagesOnlyOptimized).to.have.lengthOf(1); + assert.equal(imagesOnlyOptimized.length, 1); }); it('should not delete images that are used in other contexts', async () => { const imagesUsedElsewhere = await fixture.glob('_astro/twoofus.*.*'); - expect(imagesUsedElsewhere).to.have.lengthOf(2); + assert.equal(imagesUsedElsewhere.length, 2); }); it('should not delete images that are also used through query params', async () => { const imagesUsedElsewhere = await fixture.glob('_astro/url.*.*'); - expect(imagesUsedElsewhere).to.have.lengthOf(2); + assert.equal(imagesUsedElsewhere.length, 2); }); }); }); diff --git a/packages/astro/test/import-app.test.js b/packages/astro/test/import-app.nodetest.js similarity index 52% rename from packages/astro/test/import-app.test.js rename to packages/astro/test/import-app.nodetest.js index e0c76c5f8e..45bbbbd45d 100644 --- a/packages/astro/test/import-app.test.js +++ b/packages/astro/test/import-app.nodetest.js @@ -1,12 +1,13 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, it } from 'node:test'; describe('Import astro/app', async () => { it('Successfully imports astro/app', async () => { try { await import('astro/app'); - expect(true).to.be.true; + assert.equal(true, true); } catch (err) { - expect.fail(undefined, undefined, `Importing astro/app should not throw an error: ${err}`); + assert.fail(undefined, undefined, `Importing astro/app should not throw an error: ${err}`); } }); }); diff --git a/packages/astro/test/import-ts-with-js.test.js b/packages/astro/test/import-ts-with-js.nodetest.js similarity index 78% rename from packages/astro/test/import-ts-with-js.test.js rename to packages/astro/test/import-ts-with-js.nodetest.js index afe4a1618b..2b72a61e07 100644 --- a/packages/astro/test/import-ts-with-js.test.js +++ b/packages/astro/test/import-ts-with-js.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, it } from 'node:test'; import * as cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; @@ -14,6 +15,6 @@ describe('Using .js extension on .ts file', () => { it('works in .astro files', async () => { const html = await fixture.readFile('/index.html'); const $ = cheerio.load(html); - expect($('h1').text()).to.equal('bar'); + assert.equal($('h1').text(), 'bar'); }); }); diff --git a/packages/astro/test/impostor-mdx-file.test.js b/packages/astro/test/impostor-mdx-file.nodetest.js similarity index 81% rename from packages/astro/test/impostor-mdx-file.test.js rename to packages/astro/test/impostor-mdx-file.nodetest.js index 6f71473733..bb4dbf5f84 100644 --- a/packages/astro/test/impostor-mdx-file.test.js +++ b/packages/astro/test/impostor-mdx-file.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, it, after } from 'node:test'; import { isWindows, loadFixture } from './test-utils.js'; let fixture; @@ -25,7 +26,7 @@ describe('Impostor MDX File', () => { it('does not crash when loading react component with .md or .mdx in name', async () => { const result = await fixture.fetch('/').then((response) => response.text()); - expect(result).to.contain('Baz'); + assert.equal(result.includes('Baz'), true); }); }); }); diff --git a/packages/astro/test/integration-add-page-extension.test.js b/packages/astro/test/integration-add-page-extension.nodetest.js similarity index 77% rename from packages/astro/test/integration-add-page-extension.test.js rename to packages/astro/test/integration-add-page-extension.nodetest.js index 28c11d4fc9..f1e97d00ef 100644 --- a/packages/astro/test/integration-add-page-extension.test.js +++ b/packages/astro/test/integration-add-page-extension.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, it } from 'node:test'; import * as cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; @@ -14,6 +15,6 @@ describe('Integration addPageExtension', () => { it('supports .mjs files', async () => { const html = await fixture.readFile('/test/index.html'); const $ = cheerio.load(html); - expect($('h1').text()).to.equal('Hello world!'); + assert.equal($('h1').text(), 'Hello world!'); }); }); diff --git a/packages/astro/test/integration-server-setup.test.js b/packages/astro/test/integration-server-setup.nodetest.js similarity index 77% rename from packages/astro/test/integration-server-setup.test.js rename to packages/astro/test/integration-server-setup.nodetest.js index abe41d2bb8..45f14d708f 100644 --- a/packages/astro/test/integration-server-setup.test.js +++ b/packages/astro/test/integration-server-setup.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, it, after } from 'node:test'; import { loadFixture } from './test-utils.js'; describe('Integration server setup', () => { @@ -19,6 +20,6 @@ describe('Integration server setup', () => { it('Adds middlewares in dev', async () => { const res = await fixture.fetch('/'); - expect(res.headers.get('x-middleware')).to.equal('true'); + assert.equal(res.headers.get('x-middleware'), 'true'); }); }); diff --git a/packages/astro/test/jsx.test.js b/packages/astro/test/jsx.nodetest.js similarity index 60% rename from packages/astro/test/jsx.test.js rename to packages/astro/test/jsx.nodetest.js index b190748179..3b972a6eb0 100644 --- a/packages/astro/test/jsx.test.js +++ b/packages/astro/test/jsx.nodetest.js @@ -1,4 +1,5 @@ -import { expect } from 'chai'; +import assert from 'node:assert/strict'; +import { describe, before, it } from 'node:test'; import * as cheerio from 'cheerio'; import { loadFixture } from './test-utils.js'; @@ -16,55 +17,55 @@ describe('jsx-runtime', () => { const html = await fixture.readFile('/component/index.html'); const $ = cheerio.load(html); - expect($('#basic').text()).to.equal('Basic'); - expect($('#named').text()).to.equal('Named'); + assert.equal($('#basic').text(), 'Basic'); + assert.equal($('#named').text(), 'Named'); }); it('Can load Preact component inside Astro', async () => { const html = await fixture.readFile('/frameworks/index.html'); const $ = cheerio.load(html); - expect($('#has-preact #preact').length).to.equal(0); - expect($('#preact').text()).to.include('Preact'); + assert.equal($('#has-preact #preact').length, 0); + assert.equal($('#preact').text().includes('Preact'), true); }); it('Can load React component inside Astro', async () => { const html = await fixture.readFile('/frameworks/index.html'); const $ = cheerio.load(html); - expect($('#has-react #react').length).to.equal(0); - expect($('#react').text()).to.include('React'); + assert.equal($('#has-react #react').length, 0); + assert.equal($('#react').text().includes('React'), true); }); it('Can load Solid component inside Astro', async () => { const html = await fixture.readFile('/frameworks/index.html'); const $ = cheerio.load(html); - expect($('#has-solid #solid').length).to.equal(0); - expect($('#solid').text()).to.include('Solid'); + assert.equal($('#has-solid #solid').length, 0); + assert.equal($('#solid').text().includes('Solid'), true); }); it('Can load Svelte component inside Astro', async () => { const html = await fixture.readFile('/frameworks/index.html'); const $ = cheerio.load(html); - expect($('#has-svelte #svelte').length).to.equal(0); - expect($('#svelte').text()).to.include('Svelte'); + assert.equal($('#has-svelte #svelte').length, 0); + assert.equal($('#svelte').text().includes('Svelte'), true); }); it('Can load Vue component inside Astro', async () => { const html = await fixture.readFile('/frameworks/index.html'); const $ = cheerio.load(html); - expect($('#has-vue #vue').length).to.equal(0); - expect($('#vue').text()).to.include('Vue'); + assert.equal($('#has-vue #vue').length, 0); + assert.equal($('#vue').text().includes('Vue'), true); }); it('Can load MDX component inside Astro', async () => { const html = await fixture.readFile('/frameworks/index.html'); const $ = cheerio.load(html); - expect($('#mdx-wrapper #hello-world')).to.have.a.lengthOf(1, 'md content rendered'); - expect($('#mdx-wrapper #react')).to.have.a.lengthOf(1, 'React component rendered'); + assert.equal($('#mdx-wrapper #hello-world').length, 1, 'md content rendered'); + assert.equal($('#mdx-wrapper #react').length, 1, 'React component rendered'); }); });