summaryrefslogtreecommitdiff
path: root/packages/integrations/markdoc/test
diff options
context:
space:
mode:
Diffstat (limited to 'packages/integrations/markdoc/test')
-rw-r--r--packages/integrations/markdoc/test/content-collections.test.js21
-rw-r--r--packages/integrations/markdoc/test/fixtures/headings-custom/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/headings/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/image-assets/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json4
-rw-r--r--packages/integrations/markdoc/test/fixtures/render with-space/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-html/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-null/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-partials/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-simple/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-typographer/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-with-components/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-with-components/tsconfig.json4
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-with-config/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-with-extends-components/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/fixtures/render-with-indented-components/src/content/config.ts7
-rw-r--r--packages/integrations/markdoc/test/image-assets.test.js4
-rw-r--r--packages/integrations/markdoc/test/propagated-assets.test.js12
18 files changed, 121 insertions, 15 deletions
diff --git a/packages/integrations/markdoc/test/content-collections.test.js b/packages/integrations/markdoc/test/content-collections.test.js
index 5417f297d..48e97d45d 100644
--- a/packages/integrations/markdoc/test/content-collections.test.js
+++ b/packages/integrations/markdoc/test/content-collections.test.js
@@ -13,6 +13,8 @@ function formatPost(post) {
const root = new URL('./fixtures/content-collections/', import.meta.url);
+const sortById = (a, b) => a.id.localeCompare(b.id);
+
describe('Markdoc - Content Collections', () => {
let baseFixture;
@@ -46,7 +48,7 @@ describe('Markdoc - Content Collections', () => {
assert.notEqual(posts, null);
assert.deepEqual(
- posts.sort().map((post) => formatPost(post)),
+ posts.sort(sortById).map((post) => formatPost(post)),
[post1Entry, post2Entry, post3Entry],
);
});
@@ -68,7 +70,7 @@ describe('Markdoc - Content Collections', () => {
const posts = parseDevalue(res);
assert.notEqual(posts, null);
assert.deepEqual(
- posts.sort().map((post) => formatPost(post)),
+ posts.sort(sortById).map((post) => formatPost(post)),
[post1Entry, post2Entry, post3Entry],
);
});
@@ -83,7 +85,10 @@ const post1Entry = {
schemaWorks: true,
title: 'Post 1',
},
- body: '\n## Post 1\n\nThis is the contents of post 1.\n',
+ body: '## Post 1\n\nThis is the contents of post 1.',
+ deferredRender: true,
+ filePath: 'src/content/blog/post-1.mdoc',
+ digest: '5d5bd98d949e2b9a',
};
const post2Entry = {
@@ -94,7 +99,10 @@ const post2Entry = {
schemaWorks: true,
title: 'Post 2',
},
- body: '\n## Post 2\n\nThis is the contents of post 2.\n',
+ body: '## Post 2\n\nThis is the contents of post 2.',
+ deferredRender: true,
+ filePath: 'src/content/blog/post-2.mdoc',
+ digest: '595af4b93a4af072',
};
const post3Entry = {
@@ -105,5 +113,8 @@ const post3Entry = {
schemaWorks: true,
title: 'Post 3',
},
- body: '\n## Post 3\n\nThis is the contents of post 3.\n',
+ body: '## Post 3\n\nThis is the contents of post 3.',
+ deferredRender: true,
+ filePath: 'src/content/blog/post-3.mdoc',
+ digest: 'ef589606e542247e',
};
diff --git a/packages/integrations/markdoc/test/fixtures/headings-custom/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/headings-custom/src/content/config.ts
new file mode 100644
index 000000000..a142ace11
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/headings-custom/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const docs = defineCollection({});
+
+export const collections = {
+ docs,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/headings/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/headings/src/content/config.ts
new file mode 100644
index 000000000..a142ace11
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/headings/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const docs = defineCollection({});
+
+export const collections = {
+ docs,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/image-assets/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/image-assets/src/content/config.ts
new file mode 100644
index 000000000..a142ace11
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/image-assets/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const docs = defineCollection({});
+
+export const collections = {
+ docs,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json b/packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json
index b5bf6a715..c193287fc 100644
--- a/packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json
+++ b/packages/integrations/markdoc/test/fixtures/image-assets/tsconfig.json
@@ -5,5 +5,7 @@
"paths": {
"~/assets/*": ["src/assets/*"]
},
- }
+ },
+ "include": [".astro/types.d.ts", "**/*"],
+ "exclude": ["dist"]
}
diff --git a/packages/integrations/markdoc/test/fixtures/render with-space/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/render with-space/src/content/config.ts
new file mode 100644
index 000000000..629486e48
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render with-space/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const blog = defineCollection({});
+
+export const collections = {
+ blog,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/render-html/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/render-html/src/content/config.ts
new file mode 100644
index 000000000..629486e48
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render-html/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const blog = defineCollection({});
+
+export const collections = {
+ blog,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/render-null/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/render-null/src/content/config.ts
new file mode 100644
index 000000000..629486e48
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render-null/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const blog = defineCollection({});
+
+export const collections = {
+ blog,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/render-partials/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/render-partials/src/content/config.ts
new file mode 100644
index 000000000..629486e48
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render-partials/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const blog = defineCollection({});
+
+export const collections = {
+ blog,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/render-simple/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/render-simple/src/content/config.ts
new file mode 100644
index 000000000..629486e48
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render-simple/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const blog = defineCollection({});
+
+export const collections = {
+ blog,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/render-typographer/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/render-typographer/src/content/config.ts
new file mode 100644
index 000000000..629486e48
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render-typographer/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const blog = defineCollection({});
+
+export const collections = {
+ blog,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/render-with-components/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/render-with-components/src/content/config.ts
new file mode 100644
index 000000000..629486e48
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render-with-components/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const blog = defineCollection({});
+
+export const collections = {
+ blog,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/render-with-components/tsconfig.json b/packages/integrations/markdoc/test/fixtures/render-with-components/tsconfig.json
index 99df2e61a..f993eddf6 100644
--- a/packages/integrations/markdoc/test/fixtures/render-with-components/tsconfig.json
+++ b/packages/integrations/markdoc/test/fixtures/render-with-components/tsconfig.json
@@ -3,5 +3,7 @@
"compilerOptions": {
"jsx": "react-jsx",
"jsxImportSource": "preact"
- }
+ },
+ "include": [".astro/types.d.ts", "**/*"],
+ "exclude": ["dist"]
} \ No newline at end of file
diff --git a/packages/integrations/markdoc/test/fixtures/render-with-config/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/render-with-config/src/content/config.ts
new file mode 100644
index 000000000..629486e48
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render-with-config/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const blog = defineCollection({});
+
+export const collections = {
+ blog,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/render-with-extends-components/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/render-with-extends-components/src/content/config.ts
new file mode 100644
index 000000000..629486e48
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render-with-extends-components/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const blog = defineCollection({});
+
+export const collections = {
+ blog,
+};
diff --git a/packages/integrations/markdoc/test/fixtures/render-with-indented-components/src/content/config.ts b/packages/integrations/markdoc/test/fixtures/render-with-indented-components/src/content/config.ts
new file mode 100644
index 000000000..629486e48
--- /dev/null
+++ b/packages/integrations/markdoc/test/fixtures/render-with-indented-components/src/content/config.ts
@@ -0,0 +1,7 @@
+import { defineCollection } from 'astro:content';
+
+const blog = defineCollection({});
+
+export const collections = {
+ blog,
+};
diff --git a/packages/integrations/markdoc/test/image-assets.test.js b/packages/integrations/markdoc/test/image-assets.test.js
index 0f98af4f1..793bf1be6 100644
--- a/packages/integrations/markdoc/test/image-assets.test.js
+++ b/packages/integrations/markdoc/test/image-assets.test.js
@@ -38,7 +38,7 @@ describe('Markdoc - Image assets', () => {
const { document } = parseHTML(html);
assert.match(
document.querySelector('#relative > img')?.src,
- /\/_image\?href=.*%2Fsrc%2Fassets%2Frelative%2Foar.jpg%3ForigWidth%3D420%26origHeight%3D630%26origFormat%3Djpg&f=webp/,
+ /\/_image\?href=.*%2Fsrc%2Fassets%2Frelative%2Foar.jpg%3ForigWidth%3D420%26origHeight%3D630%26origFormat%3Djpg&w=420&h=630&f=webp/,
);
});
@@ -48,7 +48,7 @@ describe('Markdoc - Image assets', () => {
const { document } = parseHTML(html);
assert.match(
document.querySelector('#alias > img')?.src,
- /\/_image\?href=.*%2Fsrc%2Fassets%2Falias%2Fcityscape.jpg%3ForigWidth%3D420%26origHeight%3D280%26origFormat%3Djpg&f=webp/,
+ /\/_image\?href=.*%2Fsrc%2Fassets%2Falias%2Fcityscape.jpg%3ForigWidth%3D420%26origHeight%3D280%26origFormat%3Djpg&w=420&h=280&f=webp/,
);
});
diff --git a/packages/integrations/markdoc/test/propagated-assets.test.js b/packages/integrations/markdoc/test/propagated-assets.test.js
index a0768448f..5fe7369ce 100644
--- a/packages/integrations/markdoc/test/propagated-assets.test.js
+++ b/packages/integrations/markdoc/test/propagated-assets.test.js
@@ -45,12 +45,12 @@ describe('Markdoc - propagated assets', () => {
let styleContents;
if (mode === 'dev') {
const styles = stylesDocument.querySelectorAll('style');
- assert.equal(styles.length, 1);
- styleContents = styles[0].textContent;
+ assert.equal(styles.length, 2);
+ styleContents = styles[1].textContent;
} else {
const links = stylesDocument.querySelectorAll('link[rel="stylesheet"]');
- assert.equal(links.length, 1);
- styleContents = await fixture.readFile(links[0].href);
+ assert.equal(links.length, 2);
+ styleContents = await fixture.readFile(links[1].href);
}
assert.equal(styleContents.includes('--color-base-purple: 269, 79%;'), true);
});
@@ -58,10 +58,10 @@ describe('Markdoc - propagated assets', () => {
it('[fails] Does not bleed styles to other page', async () => {
if (mode === 'dev') {
const styles = scriptsDocument.querySelectorAll('style');
- assert.equal(styles.length, 0);
+ assert.equal(styles.length, 1);
} else {
const links = scriptsDocument.querySelectorAll('link[rel="stylesheet"]');
- assert.equal(links.length, 0);
+ assert.equal(links.length, 1);
}
});
});