[ci] format
This commit is contained in:
parent
21462feb4a
commit
92de6e00a3
1 changed files with 52 additions and 52 deletions
|
@ -3,62 +3,62 @@ import * as cheerio from 'cheerio';
|
||||||
import { loadFixture } from './test-utils.js';
|
import { loadFixture } from './test-utils.js';
|
||||||
|
|
||||||
describe('Public dev with base', () => {
|
describe('Public dev with base', () => {
|
||||||
/** @type {import('./test-utils').Fixture} */
|
/** @type {import('./test-utils').Fixture} */
|
||||||
let fixture;
|
let fixture;
|
||||||
/** @type {import('./test-utils').DevServer} */
|
/** @type {import('./test-utils').DevServer} */
|
||||||
let devServer;
|
let devServer;
|
||||||
let $;
|
let $;
|
||||||
|
|
||||||
before(async () => {
|
before(async () => {
|
||||||
fixture = await loadFixture({
|
fixture = await loadFixture({
|
||||||
root: './fixtures/public-base-404/',
|
root: './fixtures/public-base-404/',
|
||||||
site: 'http://example.com/',
|
site: 'http://example.com/',
|
||||||
base: '/blog'
|
base: '/blog',
|
||||||
});
|
});
|
||||||
devServer = await fixture.startDevServer();
|
devServer = await fixture.startDevServer();
|
||||||
});
|
});
|
||||||
|
|
||||||
it('200 when loading /@vite/client', async () => {
|
it('200 when loading /@vite/client', async () => {
|
||||||
const response = await fixture.fetch('/@vite/client', {
|
const response = await fixture.fetch('/@vite/client', {
|
||||||
redirect: 'manual'
|
redirect: 'manual',
|
||||||
});
|
});
|
||||||
expect(response.status).to.equal(200);
|
expect(response.status).to.equal(200);
|
||||||
const content = await response.text()
|
const content = await response.text();
|
||||||
expect(content).to.contain('vite')
|
expect(content).to.contain('vite');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('200 when loading /blog/twitter.png', async () => {
|
it('200 when loading /blog/twitter.png', async () => {
|
||||||
const response = await fixture.fetch('/blog/twitter.png', {
|
const response = await fixture.fetch('/blog/twitter.png', {
|
||||||
redirect: 'manual'
|
redirect: 'manual',
|
||||||
});
|
});
|
||||||
expect(response.status).to.equal(200);
|
expect(response.status).to.equal(200);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('custom 404 page when loading /blog/blog/', async () => {
|
it('custom 404 page when loading /blog/blog/', async () => {
|
||||||
const response = await fixture.fetch('/blog/blog/');
|
const response = await fixture.fetch('/blog/blog/');
|
||||||
const html = await response.text()
|
const html = await response.text();
|
||||||
$ = cheerio.load(html);
|
$ = cheerio.load(html);
|
||||||
expect($('h1').text()).to.equal('404');
|
expect($('h1').text()).to.equal('404');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('default 404 hint page when loading /', async () => {
|
it('default 404 hint page when loading /', async () => {
|
||||||
const response = await fixture.fetch('/');
|
const response = await fixture.fetch('/');
|
||||||
expect(response.status).to.equal(404);
|
expect(response.status).to.equal(404);
|
||||||
const html = await response.text()
|
const html = await response.text();
|
||||||
$ = cheerio.load(html);
|
$ = cheerio.load(html);
|
||||||
expect($('a').first().text()).to.equal('/blog/');
|
expect($('a').first().text()).to.equal('/blog/');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('default 404 page when loading /none/', async () => {
|
it('default 404 page when loading /none/', async () => {
|
||||||
const response = await fixture.fetch('/none/', {
|
const response = await fixture.fetch('/none/', {
|
||||||
headers: {
|
headers: {
|
||||||
accept: 'text/html,*/*'
|
accept: 'text/html,*/*',
|
||||||
}
|
},
|
||||||
});
|
});
|
||||||
expect(response.status).to.equal(404);
|
expect(response.status).to.equal(404);
|
||||||
const html = await response.text()
|
const html = await response.text();
|
||||||
$ = cheerio.load(html);
|
$ = cheerio.load(html);
|
||||||
expect($('h1').text()).to.equal('404: Not found');
|
expect($('h1').text()).to.equal('404: Not found');
|
||||||
expect($('pre').text()).to.equal('Path: /none/');
|
expect($('pre').text()).to.equal('Path: /none/');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue