0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-16 21:46:22 -05:00

chore: move tests that starts with i and j (#10129)

* chore: move tests that starts with i and j

* add missing `after`
This commit is contained in:
Emanuele Stoppa 2024-02-15 14:11:52 +00:00 committed by GitHub
parent d278e66ec6
commit 4f6b0def42
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 37 additions and 30 deletions

View file

@ -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);
});
});
});

View file

@ -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}`);
}
});
});

View file

@ -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');
});
});

View file

@ -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);
});
});
});

View file

@ -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!');
});
});

View file

@ -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');
});
});

View file

@ -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');
});
});