mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Fix Jasmine definitions
This commit is contained in:
Vendored
+266
-221
@@ -4,246 +4,291 @@
|
||||
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
|
||||
|
||||
|
||||
declare function describe(description: string, specDefinitions: Function): JasmineEnv;
|
||||
declare function xdescribe(description: string, specDefinitions: Function): JasmineEnv;
|
||||
declare function describe(description: string, specDefinitions: Function): void;
|
||||
declare function xdescribe(description: string, specDefinitions: Function): void;
|
||||
|
||||
declare function it(expectation: string, assertion: Function);
|
||||
declare function xit(expectation: string, assertion: Function);
|
||||
declare function it(expectation: string, assertion: Function): void;
|
||||
declare function xit(expectation: string, assertion: Function): void;
|
||||
|
||||
declare function beforeEach(action: Function);
|
||||
declare function afterEach(action: Function);
|
||||
declare function beforeEach(action: Function): void;
|
||||
declare function afterEach(action: Function): void;
|
||||
|
||||
declare function expect(spy: Function): JasmineSpyMatchers;
|
||||
declare function expect(spy: JasmineSpy): JasmineSpyMatchers;
|
||||
declare function expect(actual: any): JasmineMatchers;
|
||||
declare function expect(spy: Function): jasmine.Matchers;
|
||||
//declare function expect(spy: jasmine.Spy): jasmine.Matchers;
|
||||
declare function expect(actual: any): jasmine.Matchers;
|
||||
|
||||
declare function spyOn(object: any, method: string): JasmineSpyOn;
|
||||
declare function spyOn(object: any, method: string): jasmine.Spy;
|
||||
|
||||
declare function runs(asyncMethod: Function);
|
||||
declare function waitsFor(latchMethod: () => bool, failureMessage: string, timeout: number);
|
||||
|
||||
interface JasmineAny {
|
||||
constructor (expectedClass);
|
||||
jasmineMatches(other);
|
||||
jasmineToString();
|
||||
}
|
||||
|
||||
interface JasmineBlock {
|
||||
constructor (env: JasmineEnv, func: Function, spec: JasmineSpec);
|
||||
execute(onComplete);
|
||||
}
|
||||
|
||||
interface JasmineClock {
|
||||
reset(): void;
|
||||
tick(millis): void;
|
||||
runFunctionsWithinRange(oldMillis, nowMillis): void;
|
||||
scheduleFunction(timeoutKey, funcToCall, millis, recurring): void;
|
||||
useMock(): void;
|
||||
installMock(): void;
|
||||
uninstallMock(): void;
|
||||
real;
|
||||
assertInstalled(): void;
|
||||
isInstalled(): bool;
|
||||
installed: any;
|
||||
};
|
||||
|
||||
interface JasmineEnv {
|
||||
setTimeout;
|
||||
clearTimeout;
|
||||
setInterval;
|
||||
clearInterval;
|
||||
|
||||
version();
|
||||
versionString(): string;
|
||||
nextSpecId(): number;
|
||||
addReporter(reporter);
|
||||
execute();
|
||||
describe(description, specDefinitions);
|
||||
beforeEach(beforeEachFunction);
|
||||
currentRunner();
|
||||
afterEach(afterEachFunction);
|
||||
xdescribe(desc, specDefinitions);
|
||||
it(description, func);
|
||||
xit(desc, func);
|
||||
compareObjects_(a, b, mismatchKeys, mismatchValues);
|
||||
equals_(a, b, mismatchKeys, mismatchValues);
|
||||
contains_(haystack, needle);
|
||||
addEqualityTester(equalityTester);
|
||||
}
|
||||
|
||||
interface JasmineFakeTimer {
|
||||
constructor ();
|
||||
reset(): void;
|
||||
tick(millis): void;
|
||||
runFunctionsWithinRange(oldMillis, nowMillis): void;
|
||||
scheduleFunction(timeoutKey, funcToCall, millis, recurring): void;
|
||||
}
|
||||
|
||||
interface JasmineHtmlReporter {
|
||||
constructor ();
|
||||
}
|
||||
|
||||
interface JasmineNestedResults {
|
||||
constructor ();
|
||||
rollupCounts(result);
|
||||
log(values);
|
||||
getItems();
|
||||
addResult(result);
|
||||
passed();
|
||||
}
|
||||
declare function runs(asyncMethod: Function): void;
|
||||
declare function waitsFor(latchMethod: () => bool, failureMessage: string, timeout?: number): void;
|
||||
declare function waits(timeout?: number): void;
|
||||
|
||||
|
||||
interface JasminePrettyPrinter {
|
||||
constructor ();
|
||||
format(value);
|
||||
iterateObject(obj, fn);
|
||||
emitScalar(value);
|
||||
emitString(value);
|
||||
emitArray(array);
|
||||
emitObject(obj);
|
||||
append(value);
|
||||
}
|
||||
declare module jasmine {
|
||||
|
||||
interface JasmineQueue {
|
||||
constructor (env);
|
||||
addBefore(block, ensure);
|
||||
add(block, ensure);
|
||||
insertNext(block, ensure);
|
||||
start(onComplete);
|
||||
isRunning();
|
||||
next_();
|
||||
results();
|
||||
}
|
||||
var Clock: Clock;
|
||||
|
||||
interface JasmineMatchers {
|
||||
constructor (env: JasmineEnv, actual, spec: JasmineEnv, isNot?: bool);
|
||||
wrapInto_(prototype, matchersClass);
|
||||
matcherFn_(matcherName, matcherFunction);
|
||||
toBe(expected);
|
||||
toNotBe(expected);
|
||||
toEqual(expected);
|
||||
toNotEqual(expected);
|
||||
toMatch(expected);
|
||||
toNotMatch(expected);
|
||||
toBeDefined();
|
||||
toBeUndefined();
|
||||
toBeNull();
|
||||
toBeNaN();
|
||||
toBeTruthy();
|
||||
toBeFalsy();
|
||||
toHaveBeenCalled();
|
||||
wasNotCalled();
|
||||
toHaveBeenCalledWith();
|
||||
toContain(expected);
|
||||
toNotContain(expected);
|
||||
toBeLessThan(expected);
|
||||
toBeGreaterThan(expected);
|
||||
toBeCloseTo(expected, precision);
|
||||
toThrow(expected);
|
||||
function any(aclass: any);
|
||||
function createSpy(name: string): any;
|
||||
function createSpyObj(baseName: string, methodNames: any[]): any;
|
||||
|
||||
Any: JasmineAny;
|
||||
}
|
||||
function getEnv(): Env;
|
||||
|
||||
interface JasmineMultiReporter {
|
||||
constructor ();
|
||||
addReporter(reporter: JasmineReporter);
|
||||
}
|
||||
interface Any {
|
||||
|
||||
interface JasmineReporter {
|
||||
constructor ();
|
||||
reportRunnerStarting(runner);
|
||||
reportRunnerResults(runner);
|
||||
reportSuiteResults(suite);
|
||||
reportSpecStarting(spec);
|
||||
reportSpecResults(spec);
|
||||
log(str);
|
||||
}
|
||||
new (expectedClass);
|
||||
|
||||
interface JasmineRunner {
|
||||
constructor (env: JasmineEnv);
|
||||
execute();
|
||||
beforeEach(beforeEachFunction);
|
||||
afterEach(afterEachFunction);
|
||||
finishCallback();
|
||||
addSuite(suite);
|
||||
add(block);
|
||||
specs();
|
||||
suites();
|
||||
topLevelSuites();
|
||||
results();
|
||||
}
|
||||
jasmineMatches(other);
|
||||
jasmineToString();
|
||||
}
|
||||
|
||||
interface JasmineSpec {
|
||||
constructor (env: JasmineEnv, suite: JasmineSuite, description: string);
|
||||
getFullName(): string;
|
||||
results();
|
||||
log();
|
||||
runs(func: Function);
|
||||
addToQueue(block);
|
||||
addMatcherResult(result);
|
||||
expect(actual);
|
||||
// waits(timeout: number); // deprecated
|
||||
waitsFor(latchFunction: Function, timeoutMessage?: string, timeout?: number);
|
||||
fail(e);
|
||||
getMatchersClass_();
|
||||
addMatchers(matchersPrototype);
|
||||
finishCallback();
|
||||
finish(onComplete);
|
||||
after(doAfter);
|
||||
execute(onComplete);
|
||||
addBeforesAndAftersToQueue();
|
||||
explodes();
|
||||
spyOn(obj, methodName, ignoreMethodDoesntExist);
|
||||
removeAllSpies();
|
||||
}
|
||||
interface Block {
|
||||
|
||||
new (env: Env, func: Function, spec: Spec);
|
||||
|
||||
execute(onComplete);
|
||||
}
|
||||
|
||||
interface Clock {
|
||||
reset(): void;
|
||||
tick(millis): void;
|
||||
runFunctionsWithinRange(oldMillis, nowMillis): void;
|
||||
scheduleFunction(timeoutKey, funcToCall, millis, recurring): void;
|
||||
useMock(): void;
|
||||
installMock(): void;
|
||||
uninstallMock(): void;
|
||||
real;
|
||||
assertInstalled(): void;
|
||||
isInstalled(): bool;
|
||||
installed: any;
|
||||
};
|
||||
|
||||
interface Env {
|
||||
setTimeout;
|
||||
clearTimeout;
|
||||
setInterval;
|
||||
clearInterval;
|
||||
updateInterval;
|
||||
|
||||
version();
|
||||
versionString(): string;
|
||||
nextSpecId(): number;
|
||||
addReporter(reporter);
|
||||
execute();
|
||||
describe(description, specDefinitions);
|
||||
beforeEach(beforeEachFunction);
|
||||
currentRunner();
|
||||
afterEach(afterEachFunction);
|
||||
xdescribe(desc, specDefinitions);
|
||||
it(description, func);
|
||||
xit(desc, func);
|
||||
compareObjects_(a, b, mismatchKeys, mismatchValues);
|
||||
equals_(a, b, mismatchKeys, mismatchValues);
|
||||
contains_(haystack, needle);
|
||||
addEqualityTester(equalityTester);
|
||||
specFilter(spec): bool;
|
||||
}
|
||||
|
||||
interface FakeTimer {
|
||||
|
||||
new ();
|
||||
|
||||
reset(): void;
|
||||
tick(millis): void;
|
||||
runFunctionsWithinRange(oldMillis, nowMillis): void;
|
||||
scheduleFunction(timeoutKey, funcToCall, millis, recurring): void;
|
||||
}
|
||||
|
||||
interface HtmlReporter {
|
||||
new ();
|
||||
}
|
||||
|
||||
interface NestedResults {
|
||||
|
||||
new ();
|
||||
|
||||
rollupCounts(result);
|
||||
log(values);
|
||||
getItems();
|
||||
addResult(result);
|
||||
passed();
|
||||
}
|
||||
|
||||
|
||||
interface JasmineSuite {
|
||||
constructor (env: JasmineEnv, description: string, specDefinitions: Function, parentSuite: JasmineSuite);
|
||||
interface PrettyPrinter {
|
||||
|
||||
getFullName();
|
||||
finish(onComplete);
|
||||
beforeEach(beforeEachFunction);
|
||||
afterEach(afterEachFunction);
|
||||
results();
|
||||
add(suiteOrSpec);
|
||||
specs();
|
||||
suites();
|
||||
children();
|
||||
execute(onComplete);
|
||||
}
|
||||
new ();
|
||||
|
||||
interface JasmineUtil {
|
||||
inherit(childClass: Function, parentClass: Function);
|
||||
formatException(e);
|
||||
htmlEscape(str: string): string;
|
||||
argsToArray(args);
|
||||
extend(destination, source);
|
||||
}
|
||||
format(value);
|
||||
iterateObject(obj, fn);
|
||||
emitScalar(value);
|
||||
emitString(value);
|
||||
emitArray(array);
|
||||
emitObject(obj);
|
||||
append(value);
|
||||
}
|
||||
|
||||
interface JsApiReporter {
|
||||
result;
|
||||
messages;
|
||||
interface Queue {
|
||||
|
||||
constructor ();
|
||||
reportRunnerStarting(runner);
|
||||
suites();
|
||||
summarize_(suiteOrSpec);
|
||||
results();
|
||||
resultsForSpec(specId);
|
||||
reportRunnerResults(runner);
|
||||
reportSuiteResults(suite);
|
||||
reportSpecResults(spec);
|
||||
log(str);
|
||||
resultsForSpecs(specIds);
|
||||
summarizeResult_(result);
|
||||
}
|
||||
new (env);
|
||||
|
||||
interface Jasmine {
|
||||
Spec: JasmineSpec;
|
||||
Clock: JasmineClock;
|
||||
HtmlReporter: JasmineHtmlReporter;
|
||||
util: JasmineUtil;
|
||||
}
|
||||
addBefore(block, ensure);
|
||||
add(block, ensure);
|
||||
insertNext(block, ensure);
|
||||
start(onComplete);
|
||||
isRunning();
|
||||
next_();
|
||||
results();
|
||||
}
|
||||
|
||||
declare var jasmine: Jasmine;
|
||||
interface Matchers {
|
||||
|
||||
new (env: Env, actual, spec: Env, isNot?: bool);
|
||||
|
||||
toBe(expected): bool;
|
||||
toNotBe(expected): bool;
|
||||
toEqual(expected): bool;
|
||||
toNotEqual(expected): bool;
|
||||
toMatch(expected): bool;
|
||||
toNotMatch(expected): bool;
|
||||
toBeDefined(): bool;
|
||||
toBeUndefined(): bool;
|
||||
toBeNull(): bool;
|
||||
toBeNaN(): bool;
|
||||
toBeTruthy(): bool;
|
||||
toBeFalsy(): bool;
|
||||
toHaveBeenCalled(): bool;
|
||||
wasNotCalled(): bool;
|
||||
toHaveBeenCalledWith(...params: any[]): bool;
|
||||
toContain(expected): bool;
|
||||
toNotContain(expected): bool;
|
||||
toBeLessThan(expected): bool;
|
||||
toBeGreaterThan(expected): bool;
|
||||
toBeCloseTo(expected, precision): bool;
|
||||
toThrow(expected? ): bool;
|
||||
not: Matchers;
|
||||
|
||||
Any: Any;
|
||||
}
|
||||
|
||||
interface MultiReporter {
|
||||
|
||||
new ();
|
||||
|
||||
addReporter(reporter: Reporter);
|
||||
}
|
||||
|
||||
interface Reporter {
|
||||
new ();
|
||||
reportRunnerStarting(runner);
|
||||
reportRunnerResults(runner);
|
||||
reportSuiteResults(suite);
|
||||
reportSpecStarting(spec);
|
||||
reportSpecResults(spec);
|
||||
log(str);
|
||||
}
|
||||
|
||||
interface Runner {
|
||||
|
||||
new (env: Env);
|
||||
|
||||
execute();
|
||||
beforeEach(beforeEachFunction);
|
||||
afterEach(afterEachFunction);
|
||||
finishCallback();
|
||||
addSuite(suite);
|
||||
add(block);
|
||||
specs();
|
||||
suites();
|
||||
topLevelSuites();
|
||||
results();
|
||||
}
|
||||
|
||||
interface Spec {
|
||||
|
||||
new (env: Env, suite: Suite, description: string);
|
||||
|
||||
getFullName(): string;
|
||||
results();
|
||||
log();
|
||||
runs(func: Function);
|
||||
addToQueue(block);
|
||||
addMatcherResult(result);
|
||||
expect(actual);
|
||||
waitsFor(latchFunction: Function, timeoutMessage?: string, timeout?: number);
|
||||
fail(e);
|
||||
getMatchersClass_();
|
||||
addMatchers(matchersPrototype);
|
||||
finishCallback();
|
||||
finish(onComplete);
|
||||
after(doAfter);
|
||||
execute(onComplete);
|
||||
addBeforesAndAftersToQueue();
|
||||
explodes();
|
||||
spyOn(obj, methodName, ignoreMethodDoesntExist);
|
||||
removeAllSpies();
|
||||
}
|
||||
|
||||
interface Spy {
|
||||
identity: string;
|
||||
calls: any[];
|
||||
mostRecentCall: { args: any[]; };
|
||||
argsForCall: any[];
|
||||
wasCalled: bool;
|
||||
callCount: number;
|
||||
|
||||
andReturn(value): void;
|
||||
andCallThrough(): void;
|
||||
andCallFake(fakeFunc: Function): void;
|
||||
}
|
||||
|
||||
interface Suite {
|
||||
|
||||
new (env: Env, description: string, specDefinitions: Function, parentSuite: Suite);
|
||||
|
||||
getFullName();
|
||||
finish(onComplete);
|
||||
beforeEach(beforeEachFunction);
|
||||
afterEach(afterEachFunction);
|
||||
results();
|
||||
add(suiteOrSpec);
|
||||
specs();
|
||||
suites();
|
||||
children();
|
||||
execute(onComplete);
|
||||
}
|
||||
|
||||
interface Util {
|
||||
inherit(childClass: Function, parentClass: Function);
|
||||
formatException(e);
|
||||
htmlEscape(str: string): string;
|
||||
argsToArray(args);
|
||||
extend(destination, source);
|
||||
}
|
||||
|
||||
interface JsApiReporter {
|
||||
|
||||
result;
|
||||
messages;
|
||||
|
||||
new ();
|
||||
|
||||
reportRunnerStarting(runner);
|
||||
suites();
|
||||
summarize_(suiteOrSpec);
|
||||
results();
|
||||
resultsForSpec(specId);
|
||||
reportRunnerResults(runner);
|
||||
reportSuiteResults(suite);
|
||||
reportSpecResults(spec);
|
||||
log(str);
|
||||
resultsForSpecs(specIds);
|
||||
summarizeResult_(result);
|
||||
}
|
||||
|
||||
interface Jasmine {
|
||||
Spec: Spec;
|
||||
Clock: Clock;
|
||||
util: Util;
|
||||
}
|
||||
}
|
||||
@@ -436,7 +436,7 @@ describe("Asynchronous specs", () => {
|
||||
var currentWindowOnload = window.onload;
|
||||
window.onload = () => {
|
||||
if (currentWindowOnload) {
|
||||
currentWindowOnload();
|
||||
currentWindowOnload(null);
|
||||
}
|
||||
|
||||
document.querySelector('.version').innerHTML = jasmineEnv.versionString();
|
||||
|
||||
Reference in New Issue
Block a user