MCPcopy Create free account
hub / github.com/angular/angular / mergeGolden

Function mergeGolden

packages/compiler-cli/preprocessor/test/utils.ts:241–265  ·  view source on GitHub ↗
(actual: TestFile[], expected: TestFile[])

Source from the content-addressed store, hash-verified

239 * Merge actual output with expected golden file, preserving ellipses
240 */
241export async function mergeGolden(actual: TestFile[], expected: TestFile[]): Promise<TestFile[]> {
242 const expectedMap = new Map(expected.map((f) => [f.path, f.content]));
243
244 return Promise.all(
245 actual.map(async (actualFile) => {
246 const expectedContent = expectedMap.get(actualFile.path);
247 if (!expectedContent) {
248 return actualFile;
249 }
250 if (!expectedContent.includes('…')) {
251 return actualFile;
252 }
253
254 // Format expected content with placeholders to match actual formatting
255 const formattedExpected = await formatWithPlaceholders(actualFile.path, expectedContent);
256
257 // Attempt to merge
258 const mergedContent = applyEllipses(actualFile.content, formattedExpected);
259 return {
260 path: actualFile.path,
261 content: mergedContent,
262 };
263 }),
264 );
265}
266
267/**
268 * Format content that might contain ellipses by using placeholders

Callers 1

golden_spec.tsFile · 0.85

Calls 5

formatWithPlaceholdersFunction · 0.85
applyEllipsesFunction · 0.85
mapMethod · 0.80
getMethod · 0.65
allMethod · 0.45

Tested by

no test coverage detected