From 39ce218c49cc263127c79216372d9a25bc67f8cd Mon Sep 17 00:00:00 2001 From: bholmesdev Date: Tue, 7 Feb 2023 14:00:27 -0500 Subject: [PATCH] chore: unit tests --- .../content-collections/get-entry-type.test.js | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/packages/astro/test/units/content-collections/get-entry-type.test.js b/packages/astro/test/units/content-collections/get-entry-type.test.js index 3e549c2a2..e6ab3141d 100644 --- a/packages/astro/test/units/content-collections/get-entry-type.test.js +++ b/packages/astro/test/units/content-collections/get-entry-type.test.js @@ -25,13 +25,15 @@ const fixtures = [ }, ]; +const contentFileExts = ['.md', '.mdx']; + describe('Content Collections - getEntryType', () => { fixtures.forEach(({ title, contentPaths }) => { describe(title, () => { it('Returns "content" for Markdown files', () => { for (const entryPath of ['blog/first-post.md', 'blog/first-post.mdx']) { const entry = fileURLToPath(new URL(entryPath, contentPaths.contentDir)); - const type = getEntryType(entry, contentPaths); + const type = getEntryType(entry, contentPaths, contentFileExts); expect(type).to.equal('content'); } }); @@ -39,44 +41,44 @@ describe('Content Collections - getEntryType', () => { it('Returns "content" for Markdown files in nested directories', () => { for (const entryPath of ['blog/2021/01/01/index.md', 'blog/2021/01/01/index.mdx']) { const entry = fileURLToPath(new URL(entryPath, contentPaths.contentDir)); - const type = getEntryType(entry, contentPaths); + const type = getEntryType(entry, contentPaths, contentFileExts); expect(type).to.equal('content'); } }); it('Returns "config" for config files', () => { const entry = fileURLToPath(contentPaths.config.url); - const type = getEntryType(entry, contentPaths); + const type = getEntryType(entry, contentPaths, contentFileExts); expect(type).to.equal('config'); }); it('Returns "unsupported" for non-Markdown files', () => { const entry = fileURLToPath(new URL('blog/robots.txt', contentPaths.contentDir)); - const type = getEntryType(entry, contentPaths); + const type = getEntryType(entry, contentPaths, contentFileExts); expect(type).to.equal('unsupported'); }); it('Returns "ignored" for .DS_Store', () => { const entry = fileURLToPath(new URL('blog/.DS_Store', contentPaths.contentDir)); - const type = getEntryType(entry, contentPaths); + const type = getEntryType(entry, contentPaths, contentFileExts); expect(type).to.equal('ignored'); }); it('Returns "ignored" for unsupported files using an underscore', () => { const entry = fileURLToPath(new URL('blog/_draft-robots.txt', contentPaths.contentDir)); - const type = getEntryType(entry, contentPaths); + const type = getEntryType(entry, contentPaths, contentFileExts); expect(type).to.equal('ignored'); }); it('Returns "ignored" when using underscore on file name', () => { const entry = fileURLToPath(new URL('blog/_first-post.md', contentPaths.contentDir)); - const type = getEntryType(entry, contentPaths); + const type = getEntryType(entry, contentPaths, contentFileExts); expect(type).to.equal('ignored'); }); it('Returns "ignored" when using underscore on directory name', () => { const entry = fileURLToPath(new URL('blog/_draft/first-post.md', contentPaths.contentDir)); - const type = getEntryType(entry, contentPaths); + const type = getEntryType(entry, contentPaths, contentFileExts); expect(type).to.equal('ignored'); }); });