1
1
import { parseHTML } from 'linkedom' ;
2
2
import { parse as parseDevalue } from 'devalue' ;
3
3
import { expect } from 'chai' ;
4
- import { loadFixture } from '../../../astro/test/test-utils.js' ;
4
+ import { loadFixture , fixLineEndings } from '../../../astro/test/test-utils.js' ;
5
+
6
+ function formatPost ( post ) {
7
+ return {
8
+ ...post ,
9
+ body : fixLineEndings ( post . body ) ,
10
+ } ;
11
+ }
5
12
6
13
describe ( 'Markdoc - Content Collections' , ( ) => {
7
14
let fixture ;
@@ -26,14 +33,18 @@ describe('Markdoc - Content Collections', () => {
26
33
it ( 'loads entry' , async ( ) => {
27
34
const res = await fixture . fetch ( '/entry.json' ) ;
28
35
const post = parseDevalue ( await res . text ( ) ) ;
29
- expect ( post ) . to . deep . equal ( simplePostEntry ) ;
36
+ expect ( formatPost ( post ) ) . to . deep . equal ( simplePostEntry ) ;
30
37
} ) ;
31
38
32
39
it ( 'loads collection' , async ( ) => {
33
40
const res = await fixture . fetch ( '/collection.json' ) ;
34
41
const posts = parseDevalue ( await res . text ( ) ) ;
35
42
expect ( posts ) . to . not . be . null ;
36
- expect ( posts . sort ( ) ) . to . deep . equal ( [ simplePostEntry , withComponentsEntry , withConfigEntry ] ) ;
43
+ expect ( posts . sort ( ) . map ( ( post ) => formatPost ( post ) ) ) . to . deep . equal ( [
44
+ simplePostEntry ,
45
+ withComponentsEntry ,
46
+ withConfigEntry ,
47
+ ] ) ;
37
48
} ) ;
38
49
39
50
it ( 'renders content - simple' , async ( ) => {
@@ -84,14 +95,18 @@ describe('Markdoc - Content Collections', () => {
84
95
it ( 'loads entry' , async ( ) => {
85
96
const res = await fixture . readFile ( '/entry.json' ) ;
86
97
const post = parseDevalue ( res ) ;
87
- expect ( post ) . to . deep . equal ( simplePostEntry ) ;
98
+ expect ( formatPost ( post ) ) . to . deep . equal ( simplePostEntry ) ;
88
99
} ) ;
89
100
90
101
it ( 'loads collection' , async ( ) => {
91
102
const res = await fixture . readFile ( '/collection.json' ) ;
92
103
const posts = parseDevalue ( res ) ;
93
104
expect ( posts ) . to . not . be . null ;
94
- expect ( posts . sort ( ) ) . to . deep . equal ( [ simplePostEntry , withComponentsEntry , withConfigEntry ] ) ;
105
+ expect ( posts . sort ( ) . map ( ( post ) => formatPost ( post ) ) ) . to . deep . equal ( [
106
+ simplePostEntry ,
107
+ withComponentsEntry ,
108
+ withConfigEntry ,
109
+ ] ) ;
95
110
} ) ;
96
111
97
112
it ( 'renders content - simple' , async ( ) => {
0 commit comments