Home / File/ env-validators.test.js — astro Source File

env-validators.test.js — astro Source File

Architecture documentation for env-validators.test.js, a javascript file in the astro codebase. 3 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  bc34c11d_40c1_fec6_ef8f_84302d18dddd["env-validators.test.js"]
  7df3dfe3_a4d9_30de_6ea2_e2549bf58a4b["../../../dist/env/validators.js"]
  bc34c11d_40c1_fec6_ef8f_84302d18dddd --> 7df3dfe3_a4d9_30de_6ea2_e2549bf58a4b
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  bc34c11d_40c1_fec6_ef8f_84302d18dddd --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  bc34c11d_40c1_fec6_ef8f_84302d18dddd --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style bc34c11d_40c1_fec6_ef8f_84302d18dddd fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { getEnvFieldType, validateEnvVariable } from '../../../dist/env/validators.js';

/**
 * @typedef {Parameters<typeof validateEnvVariable>} Params
 */

const createFixture = () => {
	/**
	 * @type {{ value: Params[1]; options: Params[2] }} input
	 */
	let input;

	return {
		/**
		 * @param {Params[1]} value
		 * @param {Params[2]} options
		 */
		givenInput(value, options) {
			input = { value, options };
		},
		/**
		 * @param {import("../../../src/env/validators.js").ValidationResultValue} value
		 */
		thenResultShouldBeValid(value) {
			const result = validateEnvVariable(input.value, input.options);
			assert.equal(result.ok, true);
			assert.equal(result.value, value);
			input = undefined;
		},
		/**
		 * @param {string | Array<string>} providedErrors
		 */
		thenResultShouldBeInvalid(providedErrors) {
			const result = validateEnvVariable(input.value, input.options);
			assert.equal(result.ok, false);
			const errors = typeof providedErrors === 'string' ? [providedErrors] : providedErrors;
			assert.equal(
				result.errors.every((element) => errors.includes(element)),
				true,
			);
			input = undefined;
		},
	};
};

describe('astro:env validators', () => {
	/** @type {ReturnType<typeof createFixture>} */
	let fixture;

	before(() => {
		fixture = createFixture();
	});

	it('types codegen should return the right string based on the field options', () => {
		assert.equal(
			getEnvFieldType({
				type: 'string',
			}),
// ... (493 more lines)

Subdomains

Functions

Dependencies

  • ../../../dist/env/validators.js
  • node:test
  • strict

Frequently Asked Questions

What does env-validators.test.js do?
env-validators.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain, SsrAdapters subdomain.
What functions are defined in env-validators.test.js?
env-validators.test.js defines 1 function(s): createFixture.
What does env-validators.test.js depend on?
env-validators.test.js imports 3 module(s): ../../../dist/env/validators.js, node:test, strict.
Where is env-validators.test.js in the architecture?
env-validators.test.js is located at packages/astro/test/units/env/env-validators.test.js (domain: IntegrationAdapters, subdomain: SsrAdapters, directory: packages/astro/test/units/env).

Analyze Your Own Codebase

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

Try Supermodel Free