Skip to content

Commit

Permalink
hope this works pt 2
Browse files Browse the repository at this point in the history
  • Loading branch information
mAmineChniti committed Feb 3, 2024
1 parent b8bcd07 commit 6ee1b3a
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions src/__tests__/index.text.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ describe('cloneRepository', () => {
describe('updatePackageName', () => {
test('updates the package name in package.json', async () => {
const originalPackageJson = {
name: 'package.json',
name: 'catonaut',
};

const packageJsonPath = '/tmp/new-app/';
const newPackageName = 'new-name';
const packageJsonPath = '/tmp/new-app/package.json';

// mock implementation
const mockReadJson = jest.fn(() => originalPackageJson);
Expand All @@ -45,12 +46,12 @@ describe('updatePackageName', () => {
writeJson: mockWriteJson,
}));

await updatePackageName(packageJsonPath);
await updatePackageName('/tmp/new-app'); // Pass the correct path

expect(mockReadJson).toHaveBeenCalledWith(packageJsonPath + 'package.json');
expect(mockReadJson).toHaveBeenCalledWith(packageJsonPath);
expect(mockWriteJson).toHaveBeenCalledWith(
packageJsonPath,
expect.objectContaining({ name: path.basename('/tmp/new-app') }),
expect.objectContaining({ name: 'new-app' }), // Updated expectation
{ spaces: 2 }
);
});
Expand Down

0 comments on commit 6ee1b3a

Please sign in to comment.