import * as assert from 'assert' ; import { DeploymentDocument , ReferenceList } from '../../extension.bundle' ; /**
 * Given a deployment template and a character index into it, verify that getReferences on the template
 * returns the expected set of locations.
 *
 * Usually parseTemplateWithMarkers will be used to parse the document and find the indices of a set of locations
 * Example:
 *
 *      const { dt, markers: { apiVersionDef, apiVersionReference } } =  parseTemplateWithMarkers(userFuncsTemplate1, [], { ignoreWarnings: true });
 *      // Cursor at reference to "apiVersion" inside resources
 *      await testFindReferences(dt, apiVersionReference.index, [apiVersionReference.index, apiVersionDef.index]);
 */ export function testGetReferences ( dt , cursorIndexInTemplate , expectedReferenceIndices , options ? ) { const pc = dt . getContextFromDocumentCharacterIndex ( cursorIndexInTemplate , options ?. associatedDoc ) ; const references = pc . getReferences ( ) ! ; assert ( references , "Expected non-empty list of references" ) ; const indices = references . references . map ( r => r . span . startIndex ) . sort ( ) ; expectedReferenceIndices = expectedReferenceIndices . sort ( ) ; assert . deepStrictEqual ( indices , expectedReferenceIndices ) ; }