mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Update jest type definitions to 0.9.0
Add new functions and remove functions that have been dropped. From api documentation regarding unmock/dontMock: Note: this method was previously called dontMock. When using babel-jest, calls to unmock will automatically be hoisted to the top of the code block. You can use dontMock if you want to explicitly avoid this behavior.
This commit is contained in:
+9
-7
@@ -1,7 +1,7 @@
|
||||
/// <reference path="jest.d.ts" />
|
||||
|
||||
// Tests based on the Jest website
|
||||
jest.dontMock('../sum');
|
||||
jest.unmock('../sum');
|
||||
|
||||
describe('sum', function() {
|
||||
it('adds 1 + 2 to equal 3', function() {
|
||||
@@ -16,7 +16,7 @@ describe('fetchCurrentUser', function() {
|
||||
var fetchCurrentUser = require('../fetchCurrentUser');
|
||||
|
||||
// Create a mock function for our callback
|
||||
var callback = jest.genMockFunction();
|
||||
var callback = jest.fn();
|
||||
fetchCurrentUser(callback);
|
||||
|
||||
// Now we emulate the process by which `$.ajax` would execute its own
|
||||
@@ -35,7 +35,9 @@ describe('fetchCurrentUser', function() {
|
||||
});
|
||||
});
|
||||
|
||||
jest.dontMock('../displayUser.js')
|
||||
// unmock is the recommended approach for unmocking...
|
||||
jest.unmock('../displayUser.js')
|
||||
// ...but dontMock also still works.
|
||||
jest.dontMock('jquery');
|
||||
|
||||
describe('displayUser', function() {
|
||||
@@ -70,7 +72,7 @@ describe('displayUser', function() {
|
||||
});
|
||||
});
|
||||
|
||||
jest.dontMock('../CheckboxWithLabel.js');
|
||||
jest.unmock('../CheckboxWithLabel.js');
|
||||
describe('CheckboxWithLabel', function() {
|
||||
it('changes the text after click', function() {
|
||||
var React = require('react/addons');
|
||||
@@ -99,7 +101,7 @@ describe('CheckboxWithLabel', function() {
|
||||
});
|
||||
|
||||
function testInstances() {
|
||||
var mockFn = jest.genMockFunction<Function>();
|
||||
var mockFn = jest.fn<Function>();
|
||||
var a = new mockFn();
|
||||
var b = new mockFn();
|
||||
|
||||
@@ -108,7 +110,7 @@ function testInstances() {
|
||||
}
|
||||
|
||||
function testMockImplementation() {
|
||||
var mockFn = jest.genMockFunction<Function>().mockImplementation(function (scalar:number):number {
|
||||
var mockFn = jest.fn<Function>().mockImplementation(function (scalar:number):number {
|
||||
return 42 + scalar;
|
||||
});
|
||||
|
||||
@@ -120,4 +122,4 @@ function testMockImplementation() {
|
||||
|
||||
mockFn.mock.calls[0][0] === 0; // true
|
||||
mockFn.mock.calls[1][0] === 1; // true
|
||||
}
|
||||
}
|
||||
|
||||
Vendored
+3
-3
@@ -1,4 +1,4 @@
|
||||
// Type definitions for Jest 0.1.18
|
||||
// Type definitions for Jest 0.9.0
|
||||
// Project: http://facebook.github.io/jest/
|
||||
// Definitions by: Asana <https://asana.com>
|
||||
// Definitions: https://github.com/borisyankov/DefinitelyTyped
|
||||
@@ -26,15 +26,15 @@ declare module jest {
|
||||
function autoMockOn(): void;
|
||||
function clearAllTimers(): void;
|
||||
function currentTestPath(): string;
|
||||
function fn<T>(implementation?: Function): Mock<T>;
|
||||
function dontMock(moduleName: string): void;
|
||||
function genMockFromModule<T>(moduleName: string): Mock<T>;
|
||||
function genMockFunction<T>(): Mock<T>;
|
||||
function genMockFn<T>(): Mock<T>;
|
||||
function mock(moduleName: string): void;
|
||||
function runAllTicks(): void;
|
||||
function runAllTimers(): void;
|
||||
function runOnlyPendingTimers(): void;
|
||||
function setMock<T>(moduleName: string, moduleExports: T): void;
|
||||
function unmock(moduleName: string): void;
|
||||
|
||||
interface EmptyFunction {
|
||||
(): void;
|
||||
|
||||
Reference in New Issue
Block a user