From 29d4a3932658f36848cd990b3d1ebbe86eaa12ac Mon Sep 17 00:00:00 2001 From: Ruben Taelman Date: Wed, 19 May 2021 14:37:18 +0200 Subject: [PATCH] Fix failing unit tests in CI --- test/parse/ClassFinder.test.ts | 2 +- test/parse/ClassIndexer.test.ts | 3 +-- test/parse/ClassLoader.test.ts | 14 +++++++------- test/parse/ParameterResolver.test.ts | 2 +- 4 files changed, 10 insertions(+), 11 deletions(-) diff --git a/test/parse/ClassFinder.test.ts b/test/parse/ClassFinder.test.ts index 5f179b5..3292f87 100644 --- a/test/parse/ClassFinder.test.ts +++ b/test/parse/ClassFinder.test.ts @@ -56,7 +56,7 @@ describe('ClassFinder', () => { unnamed: [ { packageName: 'other-package', - fileName: Path.normalize('/some-dir/index'), + fileName: '/some-dir/index', }, ], }); diff --git a/test/parse/ClassIndexer.test.ts b/test/parse/ClassIndexer.test.ts index da3433e..ba9cae3 100644 --- a/test/parse/ClassIndexer.test.ts +++ b/test/parse/ClassIndexer.test.ts @@ -1,4 +1,3 @@ -import * as Path from 'path'; import { ClassFinder } from '../../lib/parse/ClassFinder'; import { ClassIndexer } from '../../lib/parse/ClassIndexer'; import { ClassLoader } from '../../lib/parse/ClassLoader'; @@ -292,7 +291,7 @@ export { X as B } from 'other-package' superClass: { packageName: 'other-package', localName: 'X', - fileName: Path.normalize('/some-dir/index'), + fileName: '/some-dir/index', declaration: { id: { name: 'X' }, type: 'ClassDeclaration', diff --git a/test/parse/ClassLoader.test.ts b/test/parse/ClassLoader.test.ts index a888806..777b3ad 100644 --- a/test/parse/ClassLoader.test.ts +++ b/test/parse/ClassLoader.test.ts @@ -820,7 +820,7 @@ declare interface A{} describe('importTargetToAbsolutePath', () => { it('for a local file', () => { expect(loader.importTargetToAbsolutePath('package', 'dir/lib/fileA', './subdir/fileB')) - .toEqual({ packageName: 'package', fileName: 'dir/lib/subdir/fileB' }); + .toEqual({ packageName: 'package', fileName: Path.normalize('dir/lib/subdir/fileB') }); }); it('for a package', () => { @@ -835,13 +835,13 @@ declare interface A{} }); it('for a file in a package', () => { - resolutionContext.packageNameIndexOverrides['other-package'] = '/some-dir/index.js'; + resolutionContext.packageNameIndexOverrides['other-package'] = Path.normalize('/some-dir/index.js'); expect(loader.importTargetToAbsolutePath('package', 'dir/lib/fileA', 'other-package/lib/bla')) - .toEqual({ packageName: 'other-package', fileName: '/some-dir/lib/bla' }); + .toEqual({ packageName: 'other-package', fileName: Path.normalize('/some-dir/lib/bla') }); }); it('for a scoped package', () => { - resolutionContext.packageNameIndexOverrides['@rubensworks/other-package'] = '/some-dir/index.js'; + resolutionContext.packageNameIndexOverrides['@rubensworks/other-package'] = Path.normalize('/some-dir/index.js'); expect(loader.importTargetToAbsolutePath('package', 'dir/lib/fileA', '@rubensworks/other-package')) .toEqual({ packageName: '@rubensworks/other-package', fileName: '/some-dir/index' }); }); @@ -852,9 +852,9 @@ declare interface A{} }); it('for a file in a scoped package', () => { - resolutionContext.packageNameIndexOverrides['@rubensworks/other-package'] = '/some-dir/index.js'; + resolutionContext.packageNameIndexOverrides['@rubensworks/other-package'] = Path.normalize('/some-dir/index.js'); expect(loader.importTargetToAbsolutePath('package', 'dir/lib/fileA', '@rubensworks/other-package/lib/bla')) - .toEqual({ packageName: '@rubensworks/other-package', fileName: '/some-dir/lib/bla' }); + .toEqual({ packageName: '@rubensworks/other-package', fileName: Path.normalize('/some-dir/lib/bla') }); }); }); @@ -1000,7 +1000,7 @@ declare interface A{} expect(loader.getClassElements('package', fileName, resolutionContext.parseTypescriptContents(`export * from 'other-package'`))) .toMatchObject({ exportedImportedAll: [ - { packageName: 'other-package', fileName: Path.normalize('/some-dir/index') }, + { packageName: 'other-package', fileName: '/some-dir/index' }, ], }); }); diff --git a/test/parse/ParameterResolver.test.ts b/test/parse/ParameterResolver.test.ts index a1ef5fa..a4a07d7 100644 --- a/test/parse/ParameterResolver.test.ts +++ b/test/parse/ParameterResolver.test.ts @@ -337,7 +337,7 @@ export interface MyInterface extends IgnoredInterface{}; }); describe('resolveRangeInterface', () => { - const classReference: ClassReference = { packageName: 'P', localName: 'A', fileName: 'A' }; + const classReference: ClassReferenceLoaded = { packageName: 'P', localName: 'A', fileName: 'A' }; it('should error on a non-existing interface', async() => { resolutionContext.contentsOverrides = {