Skip to content

Commit

Permalink
chore: move tests to node (#10115)
Browse files Browse the repository at this point in the history
  • Loading branch information
marwan-mohamed12 authored Feb 15, 2024
1 parent 0f3d4ae commit 40a2e03
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 21 deletions.
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand All @@ -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
);
}
});
Expand All @@ -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
);
}
});
Expand Down
Original file line number Diff line number Diff line change
@@ -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';

Expand All @@ -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');
});
});
Original file line number Diff line number Diff line change
@@ -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';

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

0 comments on commit 40a2e03

Please sign in to comment.