mirror of
https://github.com/withastro/astro.git
synced 2025-01-27 22:19:04 -05:00
chore: move tests to node (#10115)
This commit is contained in:
parent
0f3d4ae30b
commit
40a2e03ffb
3 changed files with 24 additions and 21 deletions
|
@ -1,5 +1,6 @@
|
|||
import { loadFixture } from './test-utils.js';
|
||||
import { expect } from 'chai';
|
||||
import assert from 'node:assert/strict';
|
||||
import { describe, it } from 'node:test';
|
||||
import testAdapter from './test-adapter.js';
|
||||
|
||||
describe('Adapter', () => {
|
||||
|
@ -18,8 +19,11 @@ describe('Adapter', () => {
|
|||
});
|
||||
await fixture.build();
|
||||
} catch (e) {
|
||||
expect(e.toString()).to.contain(
|
||||
"The adapter my-ssr-adapter doesn't support the feature build.excludeMiddleware."
|
||||
assert.equal(
|
||||
e
|
||||
.toString()
|
||||
.includes("The adapter my-ssr-adapter doesn't support the feature build.middleware."),
|
||||
true
|
||||
);
|
||||
}
|
||||
});
|
||||
|
@ -37,8 +41,11 @@ describe('Adapter', () => {
|
|||
});
|
||||
await fixture.build();
|
||||
} catch (e) {
|
||||
expect(e.toString()).to.contain(
|
||||
"The adapter my-ssr-adapter doesn't support the feature build.split."
|
||||
assert.equal(
|
||||
e
|
||||
.toString()
|
||||
.includes("The adapter my-ssr-adapter doesn't support the feature build.split."),
|
||||
true
|
||||
);
|
||||
}
|
||||
});
|
|
@ -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';
|
||||
|
||||
|
@ -13,30 +14,24 @@ describe('Global Fetch', () => {
|
|||
it('Is available in Astro pages', async () => {
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
expect($('#astro-page').text()).to.equal('function', 'Fetch supported in .astro page');
|
||||
assert.equal($('#astro-page').text(), 'function', 'Fetch supported in .astro page');
|
||||
});
|
||||
it('Is available in Astro components', async () => {
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
expect($('#astro-component').text()).to.equal(
|
||||
'function',
|
||||
'Fetch supported in .astro components'
|
||||
);
|
||||
assert.equal($('#astro-component').text(), 'function', 'Fetch supported in .astro components');
|
||||
});
|
||||
it('Is available in non-Astro components', async () => {
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
expect($('#jsx').text()).to.equal('function', 'Fetch supported in .jsx');
|
||||
expect($('#svelte').text()).to.equal('function', 'Fetch supported in .svelte');
|
||||
expect($('#vue').text()).to.equal('function', 'Fetch supported in .vue');
|
||||
assert.equal($('#jsx').text(), 'function', 'Fetch supported in .jsx');
|
||||
assert.equal($('#svelte').text(), 'function', 'Fetch supported in .svelte');
|
||||
assert.equal($('#vue').text(), 'function', 'Fetch supported in .vue');
|
||||
});
|
||||
it('Respects existing code', async () => {
|
||||
const html = await fixture.readFile('/index.html');
|
||||
const $ = cheerio.load(html);
|
||||
expect($('#already-imported').text()).to.equal('function', 'Existing fetch imports respected');
|
||||
expect($('#custom-declaration').text()).to.equal(
|
||||
'number',
|
||||
'Custom fetch declarations respected'
|
||||
);
|
||||
assert.equal($('#already-imported').text(), 'function', 'Existing fetch imports respected');
|
||||
assert.equal($('#custom-declaration').text(), 'number', 'Custom fetch declarations respected');
|
||||
});
|
||||
});
|
|
@ -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';
|
||||
|
||||
|
@ -15,6 +16,6 @@ describe('@fontsource/* packages', () => {
|
|||
const $ = cheerio.load(html);
|
||||
const assetPath = $('link').attr('href');
|
||||
const css = await fixture.readFile(assetPath);
|
||||
expect(css).to.contain('Montserrat');
|
||||
assert.equal(css.includes('Montserrat'), true);
|
||||
});
|
||||
});
|
Loading…
Add table
Reference in a new issue