Home / File/ print.test.js — astro Source File

print.test.js — astro Source File

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

Entity Profile

Dependency Diagram

graph LR
  c71a99d7_5f18_58db_29da_12a7e288b3be["print.test.js"]
  302610c5_2725_9f1a_b450_0bfcfb3b2d40["../dist/index.js"]
  c71a99d7_5f18_58db_29da_12a7e288b3be --> 302610c5_2725_9f1a_b450_0bfcfb3b2d40
  e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607["strict"]
  c71a99d7_5f18_58db_29da_12a7e288b3be --> e1e2fac7_5a95_7a88_cb1e_0a3b91c4e607
  6b0635f9_51ea_77aa_767b_7857878e98a6["node:test"]
  c71a99d7_5f18_58db_29da_12a7e288b3be --> 6b0635f9_51ea_77aa_767b_7857878e98a6
  style c71a99d7_5f18_58db_29da_12a7e288b3be fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import * as assert from 'node:assert/strict';
import { describe, it } from 'node:test';
import { HostRoutes, printAsRedirects } from '../dist/index.js';

describe('Printing', () => {
	it('Formats long lines in a pretty way', () => {
		const _redirects = new HostRoutes();
		_redirects.add({
			dynamic: false,
			input: '/a',
			target: '/b',
			weight: 0,
			status: 200,
		});
		_redirects.add({
			dynamic: false,
			input: '/some-pretty-long-input-line',
			target: '/b',
			weight: 0,
			status: 200,
		});
		let out = printAsRedirects(_redirects);

		let [lineOne, lineTwo] = out.split('\n');

		const indexLineOne = lineOne.indexOf('/b');
		const indexLineTwo = lineTwo.indexOf('/b');
		assert.equal(indexLineOne, indexLineTwo, 'destinations lined up');

		const newIndexLineOne = lineOne.indexOf('200');
		const newIndexLineTwo = lineTwo.indexOf('200');
		assert.equal(newIndexLineOne, newIndexLineTwo, 'statuses lined up');
	});

	it('Properly prints dynamic routes', () => {
		const _redirects = new HostRoutes();
		_redirects.add({
			dynamic: true,
			input: '/pets/:cat',
			target: '/pets/:cat/index.html',
			status: 200,
			weight: 1,
		});
		let out = printAsRedirects(_redirects);
		let parts = out.split(/\s+/);

		const expectedParts = ['/pets/:cat', '/pets/:cat/index.html', '200'];
		assert.deepEqual(parts, expectedParts);
	});

	it('Properly handles force redirects', () => {
		const _redirects = new HostRoutes();
		_redirects.add({
			dynamic: false,
			input: '/a',
			target: '/b',
			status: 200,
			weight: 1,
			force: true,
		});
		let out = printAsRedirects(_redirects);
		let parts = out.split(/\s+/);

		const expectedParts = ['/a', '/b', '200!'];
		assert.deepEqual(parts, expectedParts);
	});
});

Domain

Dependencies

  • ../dist/index.js
  • node:test
  • strict

Frequently Asked Questions

What does print.test.js do?
print.test.js is a source file in the astro codebase, written in javascript. It belongs to the CoreAstro domain.
What does print.test.js depend on?
print.test.js imports 3 module(s): ../dist/index.js, node:test, strict.
Where is print.test.js in the architecture?
print.test.js is located at packages/underscore-redirects/test/print.test.js (domain: CoreAstro, directory: packages/underscore-redirects/test).

Analyze Your Own Codebase

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

Try Supermodel Free