-
-
Notifications
You must be signed in to change notification settings - Fork 177
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(jest/lib): template mutation with createSpyObject (#209)
Fix bug causing the template object to mutate when creating spy object for jest
- Loading branch information
1 parent
093d0c9
commit e23af88
Showing
2 changed files
with
17 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { mockProvider } from '@ngneat/spectator/jest'; | ||
|
||
import { WidgetService } from '../../test/widget.service'; | ||
|
||
describe('mockProvider', () => { | ||
it('should not modify the object passed in 2nd argument when running the mock factory', () => { | ||
const customPropertiesAndMethods: Partial<Record<keyof WidgetService, any>> = { | ||
testingProperty: 'overriden' | ||
}; | ||
const { useFactory: factory } = mockProvider(WidgetService, customPropertiesAndMethods); | ||
factory(); | ||
expect(customPropertiesAndMethods).toEqual({ | ||
testingProperty: 'overriden' | ||
}); | ||
}); | ||
}); |