Initial definition for @wordpress/jest-console

This commit is contained in:
Damien SOREL
2019-03-07 13:37:18 +01:00
parent 480aadcbb3
commit b3e1195fe5
4 changed files with 89 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
// Type definitions for @wordpress/jest-console 3.0
// Project: https://github.com/wordpress/gutenberg/tree/master/packages/jest-console/readme.md
// Definitions by: Damien Sorel <https://github.com/mistic100>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 3.0
/// <reference types="jest" />
declare namespace jest {
interface Matchers<R> {
/**
* Ensure that `console.error` function was called.
*/
toHaveErrored(): R;
/**
* Ensure that `console.error` function was called with specific arguments.
*/
toHaveErroredWith(...args: any[]): R;
/**
* Ensure that `console.info` function was called.
*/
toHaveInformed(): R;
/**
* Ensure that `console.info` function was called with specific arguments.
*/
toHaveInformedWith(...args: any[]): R;
/**
* Ensure that `console.log` function was called.
*/
toHaveLogged(): R;
/**
* Ensure that `console.log` function was called with specific arguments.
*/
toHaveLoggedWith(...args: any[]): R;
/**
* Ensure that `console.warn` function was called.
*/
toHaveWarned(): R;
/**
* Ensure that `console.warn` function was called with specific arguments.
*/
toHaveWarnedWith(...args: any[]): R;
}
}

View File

@@ -0,0 +1,13 @@
it('uses the console', () => {
expect(console).toHaveErrored();
expect(console).toHaveErroredWith('message');
expect(console).toHaveInformed();
expect(console).toHaveInformedWith('message');
expect(console).toHaveLogged();
expect(console).toHaveLoggedWith('message');
expect(console).toHaveWarned();
expect(console).toHaveWarnedWith('message');
});

View File

@@ -0,0 +1,24 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6",
"dom"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"jest-console-tests.ts"
]
}

View File

@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }