Home / File/ data-collections-schema.test.js — astro Source File

data-collections-schema.test.js — astro Source File

Architecture documentation for data-collections-schema.test.js, a javascript file in the astro codebase. 5 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  ae5310e7_484b_3451_3a45_3dc3f49fd61d["data-collections-schema.test.js"]
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  ae5310e7_484b_3451_3a45_3dc3f49fd61d --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  ae5310e7_484b_3451_3a45_3dc3f49fd61d --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  ae5310e7_484b_3451_3a45_3dc3f49fd61d --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  ae5310e7_484b_3451_3a45_3dc3f49fd61d --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  6834f085_c14f_61e4_3720_10435d7dac98["fs"]
  ae5310e7_484b_3451_3a45_3dc3f49fd61d --> 6834f085_c14f_61e4_3720_10435d7dac98
  style ae5310e7_484b_3451_3a45_3dc3f49fd61d fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

// @ts-check
import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { removeDir } from '@astrojs/internal-helpers/fs';
import { loadFixture } from './test-utils.js';

describe('Content Collections - data collections', () => {
	let fixture;
	before(async () => {
		fixture = await loadFixture({ root: './fixtures/data-collections-schema/' });
		removeDir(new URL('./fixtures/data-collections-schema/.astro', import.meta.url));
		await fixture.build({});
	});

	describe('Translations Collection', () => {
		it('Generates schema file', async () => {
			const schemaExists = await fixture.pathExists('../.astro/collections/i18n.schema.json');
			assert.equal(schemaExists, true);
		});

		it('Generates schema file when the schema is a function', async () => {
			const schemaExists = await fixture.pathExists('../.astro/collections/func.schema.json');
			assert.equal(schemaExists, true);
		});

		it('Generates valid schema file', async () => {
			const rawJson = await fixture.readFile('../.astro/collections/i18n.schema.json');
			assert.deepEqual(
				JSON.stringify({
					$schema: 'https://json-schema.org/draft/2020-12/schema',
					type: 'object',
					properties: {
						homepage: {
							type: 'object',
							properties: {
								greeting: {
									type: 'string',
								},
								preamble: {
									type: 'string',
								},
							},
							required: ['greeting', 'preamble'],
							additionalProperties: false,
						},
						$schema: {
							type: 'string',
						},
					},
					required: ['homepage'],
					additionalProperties: false,
				}),
				JSON.stringify(JSON.parse(rawJson)),
			);
		});

		it('Generates schema file when the schema uses the image function', async () => {
			const schemaExists = await fixture.pathExists('../.astro/collections/image.schema.json');
			assert.equal(schemaExists, true);
		});

		it('Generates valid schema file for an image', async () => {
			const rawJson = await fixture.readFile('../.astro/collections/image.schema.json');
			assert.deepEqual(
				JSON.stringify({
					$schema: 'https://json-schema.org/draft/2020-12/schema',
					type: 'object',
					properties: {
						homepage: {
							type: 'object',
							properties: {
								greeting: {
									type: 'string',
								},
								preamble: {
									type: 'string',
								},
								image: {
									type: 'string',
								},
							},
							required: ['greeting', 'preamble', 'image'],
							additionalProperties: false,
						},
						$schema: {
							type: 'string',
						},
					},
					required: ['homepage'],
					additionalProperties: false,
				}),
				JSON.stringify(JSON.parse(rawJson)),
			);
		});
	});
});

Dependencies

Frequently Asked Questions

What does data-collections-schema.test.js do?
data-collections-schema.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does data-collections-schema.test.js depend on?
data-collections-schema.test.js imports 5 module(s): fs, loadFixture, node:test, strict, test-utils.js.
Where is data-collections-schema.test.js in the architecture?
data-collections-schema.test.js is located at packages/astro/test/data-collections-schema.test.js (domain: IntegrationAdapters, directory: packages/astro/test).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free