Home / File/ image-deletion.test.js — astro Source File

image-deletion.test.js — astro Source File

Architecture documentation for image-deletion.test.js, a javascript file in the astro codebase. 6 imports, 0 dependents.

Entity Profile

Dependency Diagram

graph LR
  e6c19fe4_b9fa_2bfa_7f4f_720c19db8491["image-deletion.test.js"]
  c7ffa4ce_010c_7ea5_dae5_5dbecd5ec1ca["test-image-service.js"]
  e6c19fe4_b9fa_2bfa_7f4f_720c19db8491 --> c7ffa4ce_010c_7ea5_dae5_5dbecd5ec1ca
  fb1cb1ea_03bd_c4c5_f29a_ff1b9c6499cd["testImageService"]
  e6c19fe4_b9fa_2bfa_7f4f_720c19db8491 --> fb1cb1ea_03bd_c4c5_f29a_ff1b9c6499cd
  0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"]
  e6c19fe4_b9fa_2bfa_7f4f_720c19db8491 --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15
  dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"]
  e6c19fe4_b9fa_2bfa_7f4f_720c19db8491 --> dd4f09ce_3fd7_8295_f616_8876cda4555c
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  e6c19fe4_b9fa_2bfa_7f4f_720c19db8491 --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  e6c19fe4_b9fa_2bfa_7f4f_720c19db8491 --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style e6c19fe4_b9fa_2bfa_7f4f_720c19db8491 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

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

describe('astro:assets - delete images that are unused', () => {
	/** @type {import('./test-utils.js').Fixture} */
	let fixture;

	describe('build ssg', () => {
		before(async () => {
			fixture = await loadFixture({
				root: './fixtures/core-image-deletion/',
				image: {
					service: testImageService(),
				},
			});

			await fixture.build();
		});

		it('should delete images that are only used for optimization', async () => {
			const imagesOnlyOptimized = await fixture.glob('_astro/onlyone.*.*');
			assert.equal(imagesOnlyOptimized.length, 1);
		});

		it('should not delete images that are used in other contexts', async () => {
			const imagesUsedElsewhere = await fixture.glob('_astro/twoofus.*.*');
			assert.equal(imagesUsedElsewhere.length, 2);
		});

		it('should not delete images that are also used through query params', async () => {
			const imagesUsedElsewhere = await fixture.glob('_astro/url.*.*');
			assert.equal(imagesUsedElsewhere.length, 2);
		});

		it('should delete MDX images only used for optimization', async () => {
			const imagesOnlyOptimized = await fixture.glob('_astro/mdxDontExist.*.*');
			assert.equal(imagesOnlyOptimized.length, 1);
		});

		it('should always keep Markdoc images', async () => {
			const imagesUsedElsewhere = await fixture.glob('_astro/markdocStillExists.*.*');
			assert.equal(imagesUsedElsewhere.length, 2);
		});
	});
});

Frequently Asked Questions

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