0
Fork 0
mirror of https://github.com/withastro/astro.git synced 2025-01-06 22:10:10 -05:00
astro/packages/astro/test/astro-pagination-root-spread.test.js
Dan Jutan 436bd09341
Fix root directory spread pagination url.prev for first page (#6183)
* Fix root pagination `url.prev` for first page

* fix lockfile?

* add changeset
2023-02-08 19:14:47 -05:00

33 lines
751 B
JavaScript

import { expect } from 'chai';
import * as cheerio from 'cheerio';
import { loadFixture } from './test-utils.js';
describe('Pagination root', () => {
let fixture;
before(async () => {
fixture = await loadFixture({
root: './fixtures/astro-pagination-root-spread/',
site: 'https://mysite.dev/',
base: '/blog',
});
await fixture.build();
});
it('correct prev url in root spread', async () => {
const prevMap = {
'/4/': '/3',
'/3/': '/2',
'/2/': '/',
'/': undefined,
};
await Promise.all(
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);
})
);
});
});