Skip to content

Commit

Permalink
Merge branch 'main' into astrojs-vercel-test-migration
Browse files Browse the repository at this point in the history
  • Loading branch information
ematipico committed Feb 12, 2024
2 parents d4aa9d1 + 1b528d2 commit 465667d
Show file tree
Hide file tree
Showing 16 changed files with 158 additions and 142 deletions.
5 changes: 5 additions & 0 deletions .changeset/poor-bees-juggle.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"astro": patch
---

Moves `shikiji-core` from `devDependencies` to `dependencies` to prevent type errors
4 changes: 2 additions & 2 deletions packages/astro/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,8 @@
"resolve": "^1.22.4",
"semver": "^7.5.4",
"server-destroy": "^1.0.1",
"shikiji": "^0.9.18",
"shikiji": "^0.9.19",
"shikiji-core": "^0.9.19",
"string-width": "^7.0.0",
"strip-ansi": "^7.1.0",
"tsconfck": "^3.0.0",
Expand Down Expand Up @@ -228,7 +229,6 @@
"remark-code-titles": "^0.1.2",
"rollup": "^4.5.0",
"sass": "^1.69.5",
"shikiji-core": "^0.9.18",
"srcset-parse": "^1.1.0",
"unified": "^11.0.4"
},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect, assert } from 'chai';
import assert from 'node:assert/strict';
import { after, describe, before, it } from 'node:test';
import { loadFixture } from './test-utils.js';

// Asset bundling
Expand All @@ -23,8 +24,9 @@ describe('Not returning responses', () => {
try {
await fixture.build();
} catch (e) {
expect(e).to.be.instanceOf(
Error,
assert.equal(
e instanceof Error,
true,
'Only instance of Response can be returned from an Astro file'
);
return null;
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 { loadFixture } from './test-utils.js';

describe('build format', () => {
Expand All @@ -17,9 +18,9 @@ describe('build format', () => {
});

it('outputs', async () => {
expect(await fixture.readFile('/client.html')).to.be.ok;
expect(await fixture.readFile('/nested-md.html')).to.be.ok;
expect(await fixture.readFile('/nested-astro.html')).to.be.ok;
assert.ok(await fixture.readFile('/client.html'));
assert.ok(await fixture.readFile('/nested-md.html'));
assert.ok(await fixture.readFile('/nested-astro.html'));
});
});

Expand All @@ -38,9 +39,9 @@ describe('build format', () => {
});

it('outputs', async () => {
expect(await fixture.readFile('/client.html')).to.be.ok;
expect(await fixture.readFile('/nested-md/index.html')).to.be.ok;
expect(await fixture.readFile('/nested-astro/index.html')).to.be.ok;
assert.ok(await fixture.readFile('/client.html'));
assert.ok(await fixture.readFile('/nested-md/index.html'));
assert.ok(await fixture.readFile('/nested-astro/index.html'));
});
});
});
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 Down Expand Up @@ -26,7 +27,7 @@ describe('Pagination root', () => {
Object.entries(prevMap).map(async ([curr, prev]) => {
const html = await fixture.readFile(curr + 'index.html');
const $ = cheerio.load(html);
expect($('#prev').attr('href')).to.equal(prev);
assert.equal($('#prev').attr('href'), prev);
})
);
});
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 @@ -20,7 +21,7 @@ describe('Pagination', () => {
'/posts/optional-root-page/2/index.html',
'/posts/optional-root-page/3/index.html',
]) {
expect(await fixture.readFile(file)).to.be.ok;
assert.ok(await fixture.readFile(file));
}
});

Expand All @@ -30,7 +31,7 @@ describe('Pagination', () => {
'/posts/named-root-page/2/index.html',
'/posts/named-root-page/3/index.html',
]) {
expect(await fixture.readFile(file)).to.be.ok;
assert.ok(await fixture.readFile(file));
}
});

Expand All @@ -44,24 +45,24 @@ describe('Pagination', () => {
params.map(async ({ color, p }) => {
const html = await fixture.readFile(`/posts/${color}/${p}/index.html`);
const $ = cheerio.load(html);
expect($('#page-param').text()).to.equal(p);
expect($('#currentPage').text()).to.equal(p);
expect($('#filter').text()).to.equal(color);
assert.equal($('#page-param').text(), p);
assert.equal($('#currentPage').text(), p);
assert.equal($('#filter').text(), color);

const prevHref = $('#prev').attr('href');
const nextHref = $('#next').attr('href');

if (color === 'red') {
expect(prevHref).to.be.undefined;
expect(nextHref).to.be.undefined;
assert.equal(prevHref, undefined);
assert.equal(nextHref, undefined);
}
if (color === 'blue' && p === '1') {
expect(prevHref).to.be.undefined;
expect(nextHref).to.equal('/posts/blue/2');
assert.equal(prevHref, undefined);
assert.equal(nextHref, '/posts/blue/2');
}
if (color === 'blue' && p === '2') {
expect(prevHref).to.equal('/posts/blue/1');
expect(nextHref).to.be.undefined;
assert.equal(prevHref, '/posts/blue/1');
assert.equal(nextHref, undefined);
}
})
);
Expand Down
19 changes: 19 additions & 0 deletions packages/astro/test/astro-public.nodetest.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import assert from 'node:assert/strict';
import { describe, before, it } from 'node:test';
import { loadFixture } from './test-utils.js';

describe('Public', () => {
let fixture;

before(async () => {
fixture = await loadFixture({ root: './fixtures/astro-public/' });
await fixture.build();
});

it('css and js files do not get bundled', async () => {
let indexHtml = await fixture.readFile('/index.html');
assert.equal(indexHtml.includes('<script src="/example.js"></script>'), true);
assert.equal(indexHtml.includes('<link href="/example.css" rel="stylesheet">'), true);
assert.equal(indexHtml.includes('<img src="/images/twitter.png">'), true);
});
});
18 changes: 0 additions & 18 deletions packages/astro/test/astro-public.test.js

This file was deleted.

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 { after, describe, before, it } from 'node:test';
import { loadFixture } from './test-utils.js';

// Asset bundling
Expand All @@ -21,6 +22,6 @@ describe('Returning responses', () => {

it('Works from a page', async () => {
let response = await fixture.fetch('/not-found');
expect(response.status).to.equal(404);
assert.equal(response.status, 404);
});
});
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 @@ -14,12 +15,12 @@ describe('Slots with client: directives', () => {
it('Tags of dynamic tags works', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('script')).to.have.a.lengthOf(1);
assert.equal($('script').length, 1);
});

it('Astro slot tags are cleaned', async () => {
const html = await fixture.readFile('/index.html');
const $ = cheerio.load(html);
expect($('astro-slot')).to.have.a.lengthOf(0);
assert.equal($('astro-slot').length, 0);
});
});

0 comments on commit 465667d

Please sign in to comment.