get-entry-type.test.js — astro Source File
Architecture documentation for get-entry-type.test.js, a javascript file in the astro codebase. 4 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d78452d0_7f99_91f4_8e11_622302cdf0b0["get-entry-type.test.js"] 4fc0ebf6_9d32_74a0_fbd7_52731484bef6["../../../dist/content/utils.js"] d78452d0_7f99_91f4_8e11_622302cdf0b0 --> 4fc0ebf6_9d32_74a0_fbd7_52731484bef6 e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] d78452d0_7f99_91f4_8e11_622302cdf0b0 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] d78452d0_7f99_91f4_8e11_622302cdf0b0 --> 6b0635f9_51ea_77aa_767b_7857878e98a6 d9a92db9_c95e_9165_13ac_24b3d859d946["node:url"] d78452d0_7f99_91f4_8e11_622302cdf0b0 --> d9a92db9_c95e_9165_13ac_24b3d859d946 style d78452d0_7f99_91f4_8e11_622302cdf0b0 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { fileURLToPath } from 'node:url';
import { getEntryType } from '../../../dist/content/utils.js';
const fixtures = [
{
title: 'Without any underscore above the content directory tree',
contentPaths: {
config: {
url: new URL('src/content.config.ts', import.meta.url),
exists: true,
},
contentDir: new URL('src/content/', import.meta.url),
root: new URL('.', import.meta.url),
},
},
{
title: 'With underscore levels above the content directory tree',
contentPaths: {
config: {
url: new URL('_src/content.config.ts', import.meta.url),
exists: true,
},
contentDir: new URL('_src/content/', import.meta.url),
root: new URL('.', import.meta.url),
},
},
];
const contentFileExts = ['.md', '.mdx'];
const dataFileExts = ['.yaml', '.yml', '.json'];
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, contentFileExts, dataFileExts);
assert.equal(type, 'content');
}
});
it('Returns "data" for JSON and YAML files', () => {
for (const entryPath of [
'banners/welcome.json',
'banners/welcome.yaml',
'banners/welcome.yml',
]) {
const entry = fileURLToPath(new URL(entryPath, contentPaths.contentDir));
const type = getEntryType(entry, contentPaths, contentFileExts, dataFileExts);
assert.equal(type, 'data');
}
});
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, contentFileExts, dataFileExts);
assert.equal(type, 'content');
}
});
it('Returns "config" for config files', () => {
const entry = fileURLToPath(contentPaths.config.url);
const type = getEntryType(entry, contentPaths, contentFileExts, dataFileExts);
assert.equal(type, 'config');
});
it('Returns "ignored" for non-Markdown files', () => {
for (const entryPath of ['blog/robots.txt', 'blog/first-post.png', '.DS_Store']) {
const entry = fileURLToPath(new URL(entryPath, contentPaths.contentDir));
const type = getEntryType(entry, contentPaths, contentFileExts, dataFileExts);
assert.equal(type, '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, contentFileExts, dataFileExts);
assert.equal(type, '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, contentFileExts, dataFileExts);
assert.equal(type, 'ignored');
});
});
});
});
Domain
Dependencies
- ../../../dist/content/utils.js
- node:test
- node:url
- strict
Source
Frequently Asked Questions
What does get-entry-type.test.js do?
get-entry-type.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does get-entry-type.test.js depend on?
get-entry-type.test.js imports 4 module(s): ../../../dist/content/utils.js, node:test, node:url, strict.
Where is get-entry-type.test.js in the architecture?
get-entry-type.test.js is located at packages/astro/test/units/content-collections/get-entry-type.test.js (domain: IntegrationAdapters, directory: packages/astro/test/units/content-collections).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free