Skip to content

Commit cb70602

Browse files
committed
chore: unit tests
1 parent 545246d commit cb70602

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

packages/astro/test/units/content-collections/get-entry-type.test.js

+10-8
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@ import { getEntryType } from '../../../dist/content/utils.js';
22
import { expect } from 'chai';
33
import { fileURLToPath } from 'node:url';
44

5+
const contentFileExts = ['.md', '.mdx'];
6+
57
describe('Content Collections - getEntryType', () => {
68
const contentDir = new URL('src/content/', import.meta.url);
79
const contentPaths = {
@@ -14,52 +16,52 @@ describe('Content Collections - getEntryType', () => {
1416
it('Returns "content" for Markdown files', () => {
1517
for (const entryPath of ['blog/first-post.md', 'blog/first-post.mdx']) {
1618
const entry = fileURLToPath(new URL(entryPath, contentDir));
17-
const type = getEntryType(entry, contentPaths);
19+
const type = getEntryType(entry, contentPaths, contentFileExts);
1820
expect(type).to.equal('content');
1921
}
2022
});
2123

2224
it('Returns "content" for Markdown files in nested directories', () => {
2325
for (const entryPath of ['blog/2021/01/01/index.md', 'blog/2021/01/01/index.mdx']) {
2426
const entry = fileURLToPath(new URL(entryPath, contentDir));
25-
const type = getEntryType(entry, contentPaths);
27+
const type = getEntryType(entry, contentPaths, contentFileExts);
2628
expect(type).to.equal('content');
2729
}
2830
});
2931

3032
it('Returns "config" for config files', () => {
3133
const entry = fileURLToPath(contentPaths.config.url);
32-
const type = getEntryType(entry, contentPaths);
34+
const type = getEntryType(entry, contentPaths, contentFileExts);
3335
expect(type).to.equal('config');
3436
});
3537

3638
it('Returns "unsupported" for non-Markdown files', () => {
3739
const entry = fileURLToPath(new URL('blog/robots.txt', contentDir));
38-
const type = getEntryType(entry, contentPaths);
40+
const type = getEntryType(entry, contentPaths, contentFileExts);
3941
expect(type).to.equal('unsupported');
4042
});
4143

4244
it('Returns "ignored" for .DS_Store', () => {
4345
const entry = fileURLToPath(new URL('blog/.DS_Store', contentDir));
44-
const type = getEntryType(entry, contentPaths);
46+
const type = getEntryType(entry, contentPaths, contentFileExts);
4547
expect(type).to.equal('ignored');
4648
});
4749

4850
it('Returns "ignored" for unsupported files using an underscore', () => {
4951
const entry = fileURLToPath(new URL('blog/_draft-robots.txt', contentDir));
50-
const type = getEntryType(entry, contentPaths);
52+
const type = getEntryType(entry, contentPaths, contentFileExts);
5153
expect(type).to.equal('ignored');
5254
});
5355

5456
it('Returns "ignored" when using underscore on file name', () => {
5557
const entry = fileURLToPath(new URL('blog/_first-post.md', contentDir));
56-
const type = getEntryType(entry, contentPaths);
58+
const type = getEntryType(entry, contentPaths, contentFileExts);
5759
expect(type).to.equal('ignored');
5860
});
5961

6062
it('Returns "ignored" when using underscore on directory name', () => {
6163
const entry = fileURLToPath(new URL('blog/_draft/first-post.md', contentDir));
62-
const type = getEntryType(entry, contentPaths);
64+
const type = getEntryType(entry, contentPaths, contentFileExts);
6365
expect(type).to.equal('ignored');
6466
});
6567
});

0 commit comments

Comments
 (0)