mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-08-16 23:10:29 +00:00
add jest mockName and getMockName (#22682)
This commit is contained in:
committed by
Mohamed Hegazy
parent
d6eafb8ea0
commit
9a4a3b6418
Vendored
+2
@@ -533,6 +533,8 @@ declare namespace jest {
|
||||
mockReturnThis(): Mock<T>;
|
||||
mockReturnValue(value: any): Mock<T>;
|
||||
mockReturnValueOnce(value: any): Mock<T>;
|
||||
mockName(name: string): Mock<T>;
|
||||
getMockName(): string;
|
||||
}
|
||||
|
||||
interface MockContext<T> {
|
||||
|
||||
@@ -311,7 +311,7 @@ describe('missing tests', () => {
|
||||
expect(jest.isMockFunction(spy)).toBeTruthy();
|
||||
});
|
||||
|
||||
it('tests all mising Mocks functionality', () => {
|
||||
it('tests all missing Mocks functionality', () => {
|
||||
type FruitsGetter = () => string[];
|
||||
const mock: jest.Mock<FruitsGetter> = jest.fn<FruitsGetter>();
|
||||
mock.mockImplementationOnce(() => ['Orange', 'Apple', 'Plum']);
|
||||
@@ -328,6 +328,12 @@ describe('missing tests', () => {
|
||||
expect(thisMock()).toBe(this);
|
||||
});
|
||||
|
||||
it('tests mock name functionality', () => {
|
||||
const mock: jest.Mock = jest.fn();
|
||||
mock.mockName('Carrot');
|
||||
expect(mock.getMockName()).toBe('Carrot');
|
||||
});
|
||||
|
||||
it('creates snapshoter', () => {
|
||||
jest.disableAutomock().mock('./render', () => jest.fn((): string => "{Link to: \"facebook\"}"), { virtual: true });
|
||||
const render: () => string = require('./render');
|
||||
|
||||
Reference in New Issue
Block a user