From e8029cd7c7ac59809b8d3da065c5df2dc7f6d255 Mon Sep 17 00:00:00 2001 From: Charlie Greenman Date: Mon, 4 Dec 2023 19:54:37 -0500 Subject: [PATCH] ZETA-7230: Complete unit tests --- .../effects/library/nextjs-library.spec.ts | 22 ++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/src/rz/nextjs/effects/library/nextjs-library.spec.ts b/src/rz/nextjs/effects/library/nextjs-library.spec.ts index a9c7f34..ca0524a 100644 --- a/src/rz/nextjs/effects/library/nextjs-library.spec.ts +++ b/src/rz/nextjs/effects/library/nextjs-library.spec.ts @@ -1,14 +1,26 @@ -import { standaloneEffects } from "../../../morph"; +import { filesToAffect, standaloneEffects } from "../../../morph"; import { EditFileEffect } from "../../../morph/interfaces/morph.interface"; import { NextjsTypeNames } from "../../types/nextjs-types"; import { returnRootTsConfig } from "./nextjs-library"; describe('Nextjs Library', () => { describe('returnRootTsConfig', () => { - it('should return the root tsconfig to modify as well as package json to get project name from', () => { - const result = returnRootTsConfig('', [], []); - expect(result).toEqual(['tsconfig.base.json']); - }); + it('should choose closest index file', () => { + const mockFilePath = 'path/to/another/src/hello.service.ts'; + const mockParameter = { + optionalTypes: {}, + type: NextjsTypeNames.Library + } as any; + + const fileTree = [ + "path/to/another/src", + "path/to/another/src/hello.component.ts", + "path/to/another/index.ts", + "path/to/another" + ]; + const fileToModify = filesToAffect(mockFilePath, fileTree, mockParameter, 'angular'); + expect(fileToModify).toEqual(['tsconfig.base.json']); + }); }); describe('libraryEffects', () => {