mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 20:02:05 +08:00
Merge pull request #21488 from Thomas-P/mochaccino
add type definitions for mochaccino
This commit is contained in:
42
types/mochaccino/index.d.ts
vendored
Normal file
42
types/mochaccino/index.d.ts
vendored
Normal file
@@ -0,0 +1,42 @@
|
||||
// Type definitions for mochaccino 1.2
|
||||
// Project: https://github.com/pawelgalazka/mochaccino#readme
|
||||
// Definitions by: Thomas-P <https://github.com/thomas-p>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
import * as Sinon from "sinon";
|
||||
export interface Expect {
|
||||
not: Expect;
|
||||
toBe(arg: any): void;
|
||||
toContain(arg: any): void;
|
||||
toEqual(arg: any): void;
|
||||
toHaveBeenCalled(): void;
|
||||
toHaveBeenCalledWith(...arg: any[]): void;
|
||||
toHaveBeenCalledTimes(callCount: number): void;
|
||||
toBeDefined(): void;
|
||||
toBeUndefined(): void;
|
||||
toBeNull(): void;
|
||||
toBeTruthy(): void;
|
||||
toBeFalsy(): void;
|
||||
toBeLessThan(other: number): void;
|
||||
toBeGreaterThan(other: number): void;
|
||||
toThrow(): void;
|
||||
toThrowError(errType: any): void;
|
||||
toMatch(matchExpression: any): void;
|
||||
}
|
||||
export interface SpyProxy {
|
||||
and: SpyProxy;
|
||||
spyProxy: true;
|
||||
getSubject: () => Sinon.SinonStub;
|
||||
callThrough: () => void;
|
||||
returnValue: (obj: any) => void;
|
||||
callFake: (fake: (...args: any[]) => any) => void;
|
||||
}
|
||||
export interface Dom {
|
||||
exposedProperties: ['window', 'navigator', 'document'];
|
||||
create: () => void;
|
||||
destroy: () => void;
|
||||
clear: () => void;
|
||||
}
|
||||
export function expect(value: any): Expect;
|
||||
export function spy(...config: any[]): (...args: any[]) => SpyProxy;
|
||||
export const dom: Dom;
|
||||
66
types/mochaccino/mochaccino-tests.ts
Normal file
66
types/mochaccino/mochaccino-tests.ts
Normal file
@@ -0,0 +1,66 @@
|
||||
import { dom, expect, spy } from 'mochaccino';
|
||||
/**
|
||||
* spy test
|
||||
*
|
||||
*/
|
||||
const obj = {
|
||||
funcName: (): any => {
|
||||
}
|
||||
};
|
||||
let s = spy();
|
||||
s(1, 2);
|
||||
expect(s).toHaveBeenCalledWith(1, 2);
|
||||
spy(obj, 'funcName');
|
||||
obj.funcName();
|
||||
expect(obj.funcName).toHaveBeenCalled();
|
||||
/***********************/
|
||||
s = spy();
|
||||
s();
|
||||
expect(s).toHaveBeenCalled();
|
||||
/***********************/
|
||||
s(obj, 'funcName').and.callFake(() => {
|
||||
return 123;
|
||||
});
|
||||
expect(obj.funcName()).toEqual(123);
|
||||
spy(obj, 'funcName');
|
||||
|
||||
expect(obj.funcName).toHaveBeenCalled();
|
||||
/***********************/
|
||||
s(obj, 'funcName').and.callThrough();
|
||||
/***********************/
|
||||
s(obj, 'funcName').and.returnValue(5);
|
||||
/***********************/
|
||||
/**
|
||||
* dom test
|
||||
*/
|
||||
dom.create();
|
||||
dom.destroy();
|
||||
dom.clear();
|
||||
/**
|
||||
* expect test
|
||||
*
|
||||
*/
|
||||
const a = 1;
|
||||
const b = true;
|
||||
const c = 2;
|
||||
const f = () => {
|
||||
};
|
||||
const ErrorType = new Error();
|
||||
const regexp = /123/;
|
||||
expect(true).toBeTruthy();
|
||||
expect(a).toBe(b);
|
||||
expect(a).toEqual(b);
|
||||
expect(a).toBeTruthy();
|
||||
expect(a).toBeFalsy();
|
||||
expect(a).toBeDefined();
|
||||
expect(a).toBeUndefined();
|
||||
expect(a).toBeNull();
|
||||
expect(a).toBeLessThan(c);
|
||||
expect(a).toBeGreaterThan(c);
|
||||
expect([1, 2]).toContain(1);
|
||||
expect(f).toThrow();
|
||||
expect(f).toThrowError(ErrorType);
|
||||
expect(s).toMatch(regexp);
|
||||
expect(s).toHaveBeenCalled();
|
||||
expect(s).toHaveBeenCalledWith(1, '23');
|
||||
expect(s).toHaveBeenCalledTimes(55);
|
||||
23
types/mochaccino/tsconfig.json
Normal file
23
types/mochaccino/tsconfig.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"strictFunctionTypes": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"mochaccino-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/mochaccino/tslint.json
Normal file
1
types/mochaccino/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user