0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2024-12-23 21:53:55 -05:00
astro/packages/astro/test/astro-pagination.test.js
Matthew Phillips e81bc3cf14
Prevent the server plugin from running during the build (#2552)
* Prevent the server plugin from running during the build

* Adds a changeset

* More all before blocks to inside of a describe()
2022-02-08 16:55:22 -05:00

47 lines
1.3 KiB
JavaScript

import { expect } from 'chai';
import cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
describe('Pagination', () => {
let fixture;
before(async () => {
fixture = await loadFixture({
projectRoot: './fixtures/astro-pagination/',
buildOptions: {
site: 'https://mysite.dev/blog/',
sitemap: false,
},
});
await fixture.build();
});
it('optional root page', async () => {
for (const file of ['/posts/optional-root-page/index.html', '/posts/optional-root-page/2/index.html', '/posts/optional-root-page/3/index.html']) {
expect(await fixture.readFile(file)).to.be.ok;
}
});
it('named root page', async () => {
for (const file of ['/posts/named-root-page/1/index.html', '/posts/named-root-page/2/index.html', '/posts/named-root-page/3/index.html']) {
expect(await fixture.readFile(file)).to.be.ok;
}
});
it('multiple params', async () => {
const params = [
{ color: 'red', p: '1' },
{ color: 'blue', p: '1' },
{ color: 'blue', p: '2' },
];
await Promise.all(
params.map(async ({ color, p }) => {
const html = await fixture.readFile(`/posts/${color}/${p}/index.html`);
const $ = cheerio.load(html);
expect($('#page-a').text()).to.equal(p);
expect($('#page-b').text()).to.equal(p);
expect($('#filter').text()).to.equal(color);
})
);
});
});