Skip to content

Commit

Permalink
Merge pull request #2 from sloughrey/multipleFuncsSameRepoMockData
Browse files Browse the repository at this point in the history
Fix issues with multiple mock datas over multiple functtions
  • Loading branch information
jazimabbas committed Aug 17, 2024
2 parents 3db1f12 + b362836 commit 24860f8
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
8 changes: 4 additions & 4 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 3 additions & 2 deletions src/mock-typeorm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,14 @@ export class MockTypeORM {
const totalMockItemsFoundInMethod = Object.keys(mockMethod).length;
mockMethod[totalMockItemsFoundInMethod] = mockData;
} else {
self.mocks[repositoryName] = { [method]: { 0: mockData } };
self.mocks[repositoryName][method] = { 0: mockData };

// initialize mock history with empty state
if (!self.mockHistory[repositoryName]) {
self.mockHistory = { ...self.mockHistory, [repositoryName]: {} };
}
self.mockHistory[repositoryName] = { [method]: 0 };

self.mockHistory[repositoryName][method] = 0;
}

return this;
Expand Down

0 comments on commit 24860f8

Please sign in to comment.