Skip to content

Commit

Permalink
ZETA-7230: Complete unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
CharlieGreenman committed Dec 5, 2023
1 parent 7842796 commit e8029cd
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/rz/nextjs/effects/library/nextjs-library.spec.ts
Original file line number Diff line number Diff line change
@@ -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', () => {
Expand Down

0 comments on commit e8029cd

Please sign in to comment.