import * as assert from 'assert' ; import * as mockery from 'mockery' ; import * as testUtils from '../testUtils' ; import { fixDriveLetterAndSlashes , properResolve } from '../../src/utils' ; import { SourceMaps } from '../../src/sourceMaps/sourceMaps' ; import { MappedPosition } from '../../src/sourceMaps/sourceMap' ; import { utils } from '../../src' ; suite ( 'SourceMaps' , ( ) => { const DIRNAME = fixDriveLetterAndSlashes ( __dirname ) ; const GENERATED_PATH = properResolve ( DIRNAME , 'testData/app.js' ) ; const AUTHORED_PATH = utils . canonicalizeUrl ( properResolve ( DIRNAME , 'testData/source1.ts' ) ) ; const ALL_SOURCES = [ AUTHORED_PATH , utils . canonicalizeUrl ( properResolve ( DIRNAME , 'testData/source2.ts' ) ) ] ; const WEBROOT = 'http://localhost' ; const PATH_MAPPING = { '/' : WEBROOT } ; const SOURCEMAP_URL = 'app.js.map' ; const sourceMaps = new SourceMaps ( PATH_MAPPING ) ; setup ( ( done ) => { testUtils . setupUnhandledRejectionListener ( ) ; mockery . enable ( { warnOnReplace : false , useCleanCache : true , warnOnUnregistered : false } ) ; testUtils . registerWin32Mocks ( ) ; testUtils . registerLocMocks ( ) ; sourceMaps . processNewSourceMap ( GENERATED_PATH , undefined , SOURCEMAP_URL ) . then ( done ) ; } ) ; teardown ( ( ) => { testUtils . removeUnhandledRejectionListener ( ) ; mockery . deregisterAll ( ) ; mockery . disable ( ) ; } ) ; test ( 'allMappedSources is case insensitive' , ( ) => { assert . deepEqual ( sourceMaps . allMappedSources ( GENERATED_PATH . toUpperCase ( ) ) , ALL_SOURCES ) ; assert . deepEqual ( sourceMaps . allMappedSources ( GENERATED_PATH . toLowerCase ( ) ) , ALL_SOURCES ) ; } ) ; test ( 'getGeneratedPathFromAuthoredPath is case insensitive' , ( ) => { assert . equal ( sourceMaps . getGeneratedPathFromAuthoredPath ( AUTHORED_PATH . toUpperCase ( ) ) , GENERATED_PATH ) ; assert . equal ( sourceMaps . getGeneratedPathFromAuthoredPath ( AUTHORED_PATH . toLowerCase ( ) ) , GENERATED_PATH ) ; } ) ; test ( 'mapToGenerated is case insensitive' , ( ) => { const position = { line : 0 , column : 0 , source : GENERATED_PATH } ; assert . deepEqual ( sourceMaps . mapToGenerated ( AUTHORED_PATH . toUpperCase ( ) , 0 , 0 ) , position ) ; assert . deepEqual ( sourceMaps . mapToGenerated ( AUTHORED_PATH . toLowerCase ( ) , 0 , 0 ) , position ) ; } ) ; test ( 'mapToAuthored is case insensitive' , ( ) => { const position = { line : 0 , column : 0 , name : null , source : AUTHORED_PATH } ; assert . deepEqual ( sourceMaps . mapToAuthored ( GENERATED_PATH . toUpperCase ( ) , 0 , 0 ) , position ) ; assert . deepEqual ( sourceMaps . mapToAuthored ( GENERATED_PATH . toLowerCase ( ) , 0 , 0 ) , position ) ; } ) ; } ) ;