Skip to content

Commit

Permalink
fix: line endings in test
Browse files Browse the repository at this point in the history
  • Loading branch information
bholmesdev committed Feb 16, 2023
1 parent f9ebf59 commit e397a80
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions packages/integrations/markdoc/test/content-collections.test.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,14 @@
import { parseHTML } from 'linkedom';
import { parse as parseDevalue } from 'devalue';
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', () => {
let fixture;
Expand All @@ -26,14 +33,18 @@ describe('Markdoc - Content Collections', () => {
it('loads entry', async () => {
const res = await fixture.fetch('/entry.json');
const post = parseDevalue(await res.text());
expect(post).to.deep.equal(simplePostEntry);
expect(formatPost(post)).to.deep.equal(simplePostEntry);
});

it('loads collection', async () => {
const res = await fixture.fetch('/collection.json');
const posts = parseDevalue(await res.text());
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 () => {
Expand Down Expand Up @@ -84,14 +95,18 @@ describe('Markdoc - Content Collections', () => {
it('loads entry', async () => {
const res = await fixture.readFile('/entry.json');
const post = parseDevalue(res);
expect(post).to.deep.equal(simplePostEntry);
expect(formatPost(post)).to.deep.equal(simplePostEntry);
});

it('loads collection', async () => {
const res = await fixture.readFile('/collection.json');
const posts = parseDevalue(res);
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 () => {
Expand Down

0 comments on commit e397a80

Please sign in to comment.