Home / File/ i18n-double-prefix.test.js — astro Source File

i18n-double-prefix.test.js — astro Source File

Architecture documentation for i18n-double-prefix.test.js, a javascript file in the astro codebase. 4 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  9e697e0d_b9e8_0074_1776_b61bc102f0de["i18n-double-prefix.test.js"]
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  9e697e0d_b9e8_0074_1776_b61bc102f0de --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  9e697e0d_b9e8_0074_1776_b61bc102f0de --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  9e697e0d_b9e8_0074_1776_b61bc102f0de --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  9e697e0d_b9e8_0074_1776_b61bc102f0de --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style 9e697e0d_b9e8_0074_1776_b61bc102f0de fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as assert from 'node:assert/strict';
import { before, describe, it } from 'node:test';
import { loadFixture } from './test-utils.js';

describe('i18n double-prefix prevention', () => {
	let fixture;

	before(async () => {
		fixture = await loadFixture({
			root: './fixtures/i18n-double-prefix/',
		});
		await fixture.build();
	});

	it('should not create double-prefixed redirect pages', async () => {
		// The Spanish page exists, so no fallback redirect should be created
		const esPage = await fixture.readFile('/es/test/item1/index.html');
		assert.ok(esPage.includes('<h1>Test Item 1 (ES)</h1>'));

		// Double-prefixed path should NOT exist
		let doublePrefix = false;
		try {
			await fixture.readFile('/es/es/test/item1/index.html');
			doublePrefix = true;
		} catch (_e) {
			// Expected - file should not exist
		}
		assert.equal(
			doublePrefix,
			false,
			'Double-prefixed path /es/es/test/item1/index.html should not exist',
		);

		// The English page should exist at its correct path
		const enPage = await fixture.readFile('/test/item1/index.html');
		assert.ok(enPage.includes('<h1>Test Item 1 (EN)</h1>'));
	});

	it('should generate correct fallback redirects for missing Spanish pages', async () => {
		// item2 only exists in English, so Spanish should fallback to English
		let spanishRedirect = false;
		try {
			await fixture.readFile('/es/test/item2/index.html');
			spanishRedirect = true;
		} catch (_e) {
			// Expected if no redirect was generated
		}

		// The English version should exist
		const enPage = await fixture.readFile('/test/item2/index.html');
		assert.ok(enPage.includes('<h1>Test Item 2 (EN only)</h1>'));

		// If a Spanish redirect was generated, it should not be double-prefixed
		if (spanishRedirect) {
			// Check that no double-prefixed version exists
			let doublePrefix = false;
			try {
				await fixture.readFile('/es/es/test/item2/index.html');
				doublePrefix = true;
			} catch (_e) {
				// Expected - double prefix should not exist
			}
			assert.equal(
				doublePrefix,
				false,
				'Double-prefixed path /es/es/test/item2/index.html should not exist',
			);
		}
	});
});

Dependencies

Frequently Asked Questions

What does i18n-double-prefix.test.js do?
i18n-double-prefix.test.js is a source file in the astro codebase, written in javascript. It belongs to the IntegrationAdapters domain.
What does i18n-double-prefix.test.js depend on?
i18n-double-prefix.test.js imports 4 module(s): loadFixture, node:test, strict, test-utils.js.
Where is i18n-double-prefix.test.js in the architecture?
i18n-double-prefix.test.js is located at packages/astro/test/i18n-double-prefix.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