core-image-service.test.js — astro Source File
Architecture documentation for core-image-service.test.js, a javascript file in the astro codebase. 7 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR 28a0e8d4_971a_de31_7103_209c0aa34aae["core-image-service.test.js"] e56262d3_c28e_c27a_bd98_fe7d33889d5f["../dist/assets/utils/vendor/image-size/lookup.js"] 28a0e8d4_971a_de31_7103_209c0aa34aae --> e56262d3_c28e_c27a_bd98_fe7d33889d5f 0a624eac_945e_c9e8_c9de_3feb9de2dd15["test-utils.js"] 28a0e8d4_971a_de31_7103_209c0aa34aae --> 0a624eac_945e_c9e8_c9de_3feb9de2dd15 dd4f09ce_3fd7_8295_f616_8876cda4555c["loadFixture"] 28a0e8d4_971a_de31_7103_209c0aa34aae --> dd4f09ce_3fd7_8295_f616_8876cda4555c e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"] 28a0e8d4_971a_de31_7103_209c0aa34aae --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607 6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"] 28a0e8d4_971a_de31_7103_209c0aa34aae --> 6b0635f9_51ea_77aa_767b_7857878e98a6 6834f085_c14f_61e4_3720_10435d7dac98["fs"] 28a0e8d4_971a_de31_7103_209c0aa34aae --> 6834f085_c14f_61e4_3720_10435d7dac98 deb87372_5629_35f8_9a54_e755a08f776a["cheerio"] 28a0e8d4_971a_de31_7103_209c0aa34aae --> deb87372_5629_35f8_9a54_e755a08f776a style 28a0e8d4_971a_de31_7103_209c0aa34aae fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
import assert from 'node:assert/strict';
import { after, before, describe, it } from 'node:test';
import { removeDir } from '@astrojs/internal-helpers/fs';
import * as cheerio from 'cheerio';
import { lookup as probe } from '../dist/assets/utils/vendor/image-size/lookup.js';
import { loadFixture } from './test-utils.js';
async function getImageDimensionsFromFixture(fixture, path) {
/** @type { Response } */
const res = await fixture.fetch(path instanceof URL ? path.pathname + path.search : path);
const buffer = await res.arrayBuffer();
const { width, height } = await probe(new Uint8Array(buffer));
return { width, height };
}
async function getImageDimensionsFromLocalFile(fixture, path) {
const buffer = await fixture.readFile(path, null);
const { width, height } = await probe(new Uint8Array(buffer));
return { width, height };
}
describe('astro image service', () => {
/** @type {import('./test-utils').Fixture} */
let fixture;
describe('dev image service', () => {
/** @type {import('./test-utils').DevServer} */
let devServer;
before(async () => {
fixture = await loadFixture({
root: './fixtures/core-image-layout/',
image: {
domains: ['unsplash.com'],
},
});
devServer = await fixture.startDevServer({});
});
after(async () => {
await devServer.stop();
});
describe('generated images', () => {
let $;
let src;
before(async () => {
const res = await fixture.fetch('/fit');
const html = await res.text();
$ = cheerio.load(html);
let $img = $('#local-both img');
src = new URL($img.attr('src'), 'http://localhost').href;
});
it('generates correct width and height when both are provided', async () => {
const url = new URL(src);
const { width, height } = await getImageDimensionsFromFixture(fixture, url);
assert.equal(width, 300);
assert.equal(height, 400);
// ... (145 more lines)
Domain
Subdomains
Dependencies
- ../dist/assets/utils/vendor/image-size/lookup.js
- cheerio
- fs
- loadFixture
- node:test
- strict
- test-utils.js
Source
Frequently Asked Questions
What does core-image-service.test.js do?
core-image-service.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 core-image-service.test.js?
core-image-service.test.js defines 2 function(s): getImageDimensionsFromFixture, getImageDimensionsFromLocalFile.
What does core-image-service.test.js depend on?
core-image-service.test.js imports 7 module(s): ../dist/assets/utils/vendor/image-size/lookup.js, cheerio, fs, loadFixture, node:test, strict, test-utils.js.
Where is core-image-service.test.js in the architecture?
core-image-service.test.js is located at packages/astro/test/core-image-service.test.js (domain: IntegrationAdapters, subdomain: SsrAdapters, directory: packages/astro/test).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free