@@ -2,6 +2,8 @@ import { getEntryType } from '../../../dist/content/utils.js';
2
2
import { expect } from 'chai' ;
3
3
import { fileURLToPath } from 'node:url' ;
4
4
5
+ const contentFileExts = [ '.md' , '.mdx' ] ;
6
+
5
7
describe ( 'Content Collections - getEntryType' , ( ) => {
6
8
const contentDir = new URL ( 'src/content/' , import . meta. url ) ;
7
9
const contentPaths = {
@@ -14,52 +16,52 @@ describe('Content Collections - getEntryType', () => {
14
16
it ( 'Returns "content" for Markdown files' , ( ) => {
15
17
for ( const entryPath of [ 'blog/first-post.md' , 'blog/first-post.mdx' ] ) {
16
18
const entry = fileURLToPath ( new URL ( entryPath , contentDir ) ) ;
17
- const type = getEntryType ( entry , contentPaths ) ;
19
+ const type = getEntryType ( entry , contentPaths , contentFileExts ) ;
18
20
expect ( type ) . to . equal ( 'content' ) ;
19
21
}
20
22
} ) ;
21
23
22
24
it ( 'Returns "content" for Markdown files in nested directories' , ( ) => {
23
25
for ( const entryPath of [ 'blog/2021/01/01/index.md' , 'blog/2021/01/01/index.mdx' ] ) {
24
26
const entry = fileURLToPath ( new URL ( entryPath , contentDir ) ) ;
25
- const type = getEntryType ( entry , contentPaths ) ;
27
+ const type = getEntryType ( entry , contentPaths , contentFileExts ) ;
26
28
expect ( type ) . to . equal ( 'content' ) ;
27
29
}
28
30
} ) ;
29
31
30
32
it ( 'Returns "config" for config files' , ( ) => {
31
33
const entry = fileURLToPath ( contentPaths . config . url ) ;
32
- const type = getEntryType ( entry , contentPaths ) ;
34
+ const type = getEntryType ( entry , contentPaths , contentFileExts ) ;
33
35
expect ( type ) . to . equal ( 'config' ) ;
34
36
} ) ;
35
37
36
38
it ( 'Returns "unsupported" for non-Markdown files' , ( ) => {
37
39
const entry = fileURLToPath ( new URL ( 'blog/robots.txt' , contentDir ) ) ;
38
- const type = getEntryType ( entry , contentPaths ) ;
40
+ const type = getEntryType ( entry , contentPaths , contentFileExts ) ;
39
41
expect ( type ) . to . equal ( 'unsupported' ) ;
40
42
} ) ;
41
43
42
44
it ( 'Returns "ignored" for .DS_Store' , ( ) => {
43
45
const entry = fileURLToPath ( new URL ( 'blog/.DS_Store' , contentDir ) ) ;
44
- const type = getEntryType ( entry , contentPaths ) ;
46
+ const type = getEntryType ( entry , contentPaths , contentFileExts ) ;
45
47
expect ( type ) . to . equal ( 'ignored' ) ;
46
48
} ) ;
47
49
48
50
it ( 'Returns "ignored" for unsupported files using an underscore' , ( ) => {
49
51
const entry = fileURLToPath ( new URL ( 'blog/_draft-robots.txt' , contentDir ) ) ;
50
- const type = getEntryType ( entry , contentPaths ) ;
52
+ const type = getEntryType ( entry , contentPaths , contentFileExts ) ;
51
53
expect ( type ) . to . equal ( 'ignored' ) ;
52
54
} ) ;
53
55
54
56
it ( 'Returns "ignored" when using underscore on file name' , ( ) => {
55
57
const entry = fileURLToPath ( new URL ( 'blog/_first-post.md' , contentDir ) ) ;
56
- const type = getEntryType ( entry , contentPaths ) ;
58
+ const type = getEntryType ( entry , contentPaths , contentFileExts ) ;
57
59
expect ( type ) . to . equal ( 'ignored' ) ;
58
60
} ) ;
59
61
60
62
it ( 'Returns "ignored" when using underscore on directory name' , ( ) => {
61
63
const entry = fileURLToPath ( new URL ( 'blog/_draft/first-post.md' , contentDir ) ) ;
62
- const type = getEntryType ( entry , contentPaths ) ;
64
+ const type = getEntryType ( entry , contentPaths , contentFileExts ) ;
63
65
expect ( type ) . to . equal ( 'ignored' ) ;
64
66
} ) ;
65
67
} ) ;
0 commit comments