fix: line endings in test
This commit is contained in:
parent
23e2511a2e
commit
344550c0b2
1 changed files with 20 additions and 5 deletions
|
@ -1,7 +1,14 @@
|
||||||
import { parseHTML } from 'linkedom';
|
import { parseHTML } from 'linkedom';
|
||||||
import { parse as parseDevalue } from 'devalue';
|
import { parse as parseDevalue } from 'devalue';
|
||||||
import { expect } from 'chai';
|
import { expect } from 'chai';
|
||||||
import { loadFixture } from '../../../astro/test/test-utils.js';
|
import { loadFixture, fixLineEndings } from '../../../astro/test/test-utils.js';
|
||||||
|
|
||||||
|
function formatPost(post) {
|
||||||
|
return {
|
||||||
|
...post,
|
||||||
|
body: fixLineEndings(post.body),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
describe('Markdoc - Content Collections', () => {
|
describe('Markdoc - Content Collections', () => {
|
||||||
let fixture;
|
let fixture;
|
||||||
|
@ -26,14 +33,18 @@ describe('Markdoc - Content Collections', () => {
|
||||||
it('loads entry', async () => {
|
it('loads entry', async () => {
|
||||||
const res = await fixture.fetch('/entry.json');
|
const res = await fixture.fetch('/entry.json');
|
||||||
const post = parseDevalue(await res.text());
|
const post = parseDevalue(await res.text());
|
||||||
expect(post).to.deep.equal(simplePostEntry);
|
expect(formatPost(post)).to.deep.equal(simplePostEntry);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('loads collection', async () => {
|
it('loads collection', async () => {
|
||||||
const res = await fixture.fetch('/collection.json');
|
const res = await fixture.fetch('/collection.json');
|
||||||
const posts = parseDevalue(await res.text());
|
const posts = parseDevalue(await res.text());
|
||||||
expect(posts).to.not.be.null;
|
expect(posts).to.not.be.null;
|
||||||
expect(posts.sort()).to.deep.equal([simplePostEntry, withComponentsEntry, withConfigEntry]);
|
expect(posts.sort().map((post) => formatPost(post))).to.deep.equal([
|
||||||
|
simplePostEntry,
|
||||||
|
withComponentsEntry,
|
||||||
|
withConfigEntry,
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders content - simple', async () => {
|
it('renders content - simple', async () => {
|
||||||
|
@ -84,14 +95,18 @@ describe('Markdoc - Content Collections', () => {
|
||||||
it('loads entry', async () => {
|
it('loads entry', async () => {
|
||||||
const res = await fixture.readFile('/entry.json');
|
const res = await fixture.readFile('/entry.json');
|
||||||
const post = parseDevalue(res);
|
const post = parseDevalue(res);
|
||||||
expect(post).to.deep.equal(simplePostEntry);
|
expect(formatPost(post)).to.deep.equal(simplePostEntry);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('loads collection', async () => {
|
it('loads collection', async () => {
|
||||||
const res = await fixture.readFile('/collection.json');
|
const res = await fixture.readFile('/collection.json');
|
||||||
const posts = parseDevalue(res);
|
const posts = parseDevalue(res);
|
||||||
expect(posts).to.not.be.null;
|
expect(posts).to.not.be.null;
|
||||||
expect(posts.sort()).to.deep.equal([simplePostEntry, withComponentsEntry, withConfigEntry]);
|
expect(posts.sort().map((post) => formatPost(post))).to.deep.equal([
|
||||||
|
simplePostEntry,
|
||||||
|
withComponentsEntry,
|
||||||
|
withConfigEntry,
|
||||||
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('renders content - simple', async () => {
|
it('renders content - simple', async () => {
|
||||||
|
|
Loading…
Reference in a new issue