astro/packages/astro/test/astro-collection.test.js
Nate Moore 3ad0aac8cf
Fix fetchContent for nested files (#171)
* fix: fetchContent within nested folders

* feat: add `sourceId` to fetchContent

* test: update collection tests

* fix: windows compat for importPath

* chore: add changeset

* fix: astroRoot => projectRoot

* feat: add `slash` package

* chore: remove sourceId prop

* chore: update changeset

* format
2021-05-04 17:11:05 -05:00

30 lines
950 B
JavaScript

import { suite } from 'uvu';
import * as assert from 'uvu/assert';
import { doc } from './test-utils.js';
import { setup } from './helpers.js';
const Collections = suite('Collections');
setup(Collections, './fixtures/astro-collection');
Collections('generates list & sorts successfully', async ({ runtime }) => {
const result = await runtime.load('/posts');
const $ = doc(result.contents);
const urls = [
...$('#posts a').map(function () {
return $(this).attr('href');
}),
];
assert.equal(urls, ['/post/nested/a', '/post/three', '/post/two']);
});
Collections('generates pagination successfully', async ({ runtime }) => {
const result = await runtime.load('/posts');
const $ = doc(result.contents);
const prev = $('#prev-page');
const next = $('#next-page');
assert.equal(prev.length, 0); // this is first page; should be missing
assert.equal(next.length, 1); // this should be on-page
});
Collections.run();