Merge pull request #918 from gstamac/master

Jasmine-jQuery tests and Jasmine fixes
This commit is contained in:
Boris Yankov
2013-08-23 05:59:34 -07:00
5 changed files with 413 additions and 189 deletions
+1
View File
@@ -91,6 +91,7 @@ List of Definitions
* [iScroll](http://cubiq.org/iscroll-4) (by [Boris Yankov](https://github.com/borisyankov))
* [jake](https://github.com/mde/jake) (by [Kon](http://phyzkit.net/))
* [Jasmine](http://pivotal.github.com/jasmine/) (by [Boris Yankov](https://github.com/borisyankov))
* [Jasmine-jQuery](https://github.com/velesin/jasmine-jquery) (by [Gregor Stamac](https://github.com/gstamac))
* [jQRangeSlider](http://ghusse.github.com/jQRangeSlider) (by [Dániel Tar](https://github.com/qcz))
* [jQuery](http://jquery.com/) (from TypeScript samples)
* [jQuery Mobile](http://jquerymobile.com) (by [Boris Yankov](https://github.com/borisyankov))
+135
View File
@@ -0,0 +1,135 @@
/// <reference path="../jasmine/jasmine.d.ts" />
/// <reference path="../jquery/jquery.d.ts" />
/// <reference path="jasmine-jquery.d.ts" />
describe("Jasmine jQuery extension", () => {
it("Adds jQuery matchers", () => {
expect($('<div id="some-id"></div>')).toBe('div');
expect($('<div id="some-id"></div>')).toBe('div#some-id');
expect($('<input type="checkbox" checked="checked"/>')).toBeChecked();
expect($('<div id="some-id"></div>')).toBeHidden();
expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({ display: "none", margin: "10px" });
expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({ margin: "10px" });
expect($('<option selected="selected"></option>')).toBeSelected();
expect($('<div id="some-id"></div>')).toBeVisible();
expect($('<div><span class="some-class"></span></div>')).toContain('span.some-class');
expect($('<span></span>').addClass('js-something')).toBeMatchedBy('.js-something');
expect($('<span></span>')).toExist();
expect($('<div id="some-id"></div>')).toHaveAttr('id', 'some-id');
expect($('<div id="some-id"></div>')).toHaveProp('id', 'some-id');
expect($('')).toHaveBeenTriggered();
expect($('')).toHaveBeenTriggeredOn('#some-id');
expect($('')).toHaveBeenTriggeredOnAndWith('#some-id', 'eventParam');
expect($('')).toHaveBeenPrevented();
expect($('')).toHaveBeenPreventedOn('#some-id');
expect($('')).toHaveBeenStopped();
expect($('')).toHaveBeenStoppedOn('#some-id');
expect($('<div class="some-class"></div>')).toHaveClass("some-class");
expect($('<div data-item="value"></div>')).toHaveData('item', 'value');
expect($('<div><span></span></div>')).toHaveHtml('<span></span>');
expect($('<div><ul></ul><h1>header</h1></div>')).toContainHtml('<ul></ul>');
expect($('<div><ul></ul><h1>header</h1></div>')).toContainText('header');
expect($('<div id="some-id"></div>')).toHaveId("some-id");
expect($('<div>some text</div>')).toHaveText('some text');
expect($('<input type="text" value="some text"/>')).toHaveValue('some text');
expect($('ul > li')).toHaveLength(3);
expect($('<input type="submit" disabled ="disabled"/>')).toBeDisabled();
expect($('<input type="text" />').focus()).toBeFocused();
//expect($form).toHandle("submit")
//expect($form).toHandleWith("submit", yourSubmitCallback)
});
it("Handles HTML Fixtures", () => {
jasmine.getFixtures().fixturesPath = 'my/new/path';
jasmine.getFixtures().containerId = 'my-new-id';
jasmine.getFixtures().load('myfixture.html');
jasmine.getFixtures().appendLoad('myfixture.html', 'myfixture2.html');
jasmine.getFixtures().read('myfixture.html', 'myfixture2.html');
jasmine.getFixtures().set('<html></html>');
jasmine.getFixtures().appendSet('<html></html>');
jasmine.getFixtures().preload('myfixture.html', 'myfixture2.html');
jasmine.getFixtures().clearCache();
jasmine.getFixtures().cleanUp();
loadFixtures('myfixture.html');
appendLoadFixtures('myfixture.html');
readFixtures('myfixture.html');
setFixtures('<html></html>');
appendSetFixtures('<html></html>');
sandbox();
sandbox({
id: 'my-id',
class: 'my-class',
myattr: 'my-attr'
});
setFixtures(sandbox({ class: 'my-class' }));
});
it("Handles Style Fixtures", () => {
jasmine.getStyleFixtures().fixturesPath = 'my/new/path';
jasmine.getStyleFixtures().load('myfixture.css');
jasmine.getStyleFixtures().appendLoad('myfixture.css', 'myfixture2.css');
jasmine.getStyleFixtures().set('.elem { position: absolute }');
jasmine.getStyleFixtures().appendSet('.elem { position: absolute }');
jasmine.getStyleFixtures().preload('myfixture.css', 'myfixture2.css');
jasmine.getStyleFixtures().clearCache();
jasmine.getStyleFixtures().cleanUp();
loadStyleFixtures('myfixture.css');
appendLoadFixtures('myfixture.css');
setStyleFixtures('.elem { position: absolute }');
appendSetStyleFixtures('.elem { position: absolute }');
});
it("Handles JSON Fixtures", () => {
jasmine.getJSONFixtures().fixturesPath = 'my/new/path';
jasmine.getJSONFixtures().load('myfixture.json');
jasmine.getJSONFixtures().read('myfixture.json');
jasmine.getJSONFixtures().clearCache();
var data = getJSONFixture('myjsonfixture.json');
var fixtures = loadJSONFixtures('myjsonfixture.json');
var data = fixtures['myjsonfixture.json'];
});
describe("Event Spies", () => {
it("First, spy on the event", () => {
var spyEvent = spyOnEvent('#some_element', 'click');
$('#some_element').click();
expect('click').toHaveBeenTriggeredOn('#some_element');
expect(spyEvent).toHaveBeenTriggered();
});
it("You can reset spy events", () => {
var spyEvent = spyOnEvent('#some_element', 'click');
$('#some_element').click();
expect('click').toHaveBeenTriggeredOn('#some_element');
expect(spyEvent).toHaveBeenTriggered();
// reset spy events
spyEvent.reset();
expect('click').not.toHaveBeenTriggeredOn('#some_element');
expect(spyEvent).not.toHaveBeenTriggered();
});
it("You can similarly check if triggered event was prevented", () => {
var spyEvent = spyOnEvent('#some_element', 'click');
$('#some_element').click(function (event) { event.preventDefault(); });
$('#some_element').click();
expect('click').toHaveBeenPreventedOn('#some_element');
expect(spyEvent).toHaveBeenPrevented();
});
it("You can also check if the triggered event was stopped", () => {
var spyEvent = spyOnEvent('#some_element', 'click');
$('#some_element').click(function (event) { event.stopPropagation(); });
$('#some_element').click();
expect('click').toHaveBeenStoppedOn('#some_element');
expect(spyEvent).toHaveBeenStopped();
});
});
})
+44 -22
View File
@@ -3,24 +3,29 @@
// Definitions by: Gregor Stamac <https://github.com/gstamac/>
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../jasmine/jasmine.d.ts"/>
/// <reference path="../jquery/jquery.d.ts"/>
declare function sandbox(attributes?: any): string;
declare function readFixtures(...uls: string[]): string;
declare function preloadFixtures(...uls: string[]);
declare function loadFixtures(...uls: string[]);
declare function appendLoadFixtures(...uls: string[]);
declare function setFixtures(html: string): string;
declare function appendSetFixtures();
declare function sandbox(attributes): JQuery;
declare function spyOnEvent(selector: JQuery, eventName: string): any;
declare function preloadStyleFixtures();
declare function loadStyleFixtures();
declare function appendLoadStyleFixtures();
declare function appendSetFixtures(html: string);
declare function preloadStyleFixtures(...uls: string[]);
declare function loadStyleFixtures(...uls: string[]);
declare function appendLoadStyleFixtures(...uls: string[]);
declare function setStyleFixtures(html: string);
declare function appendSetStyleFixtures(html: string);
declare function loadJSONFixtures(): jasmine.JSONFixtures;
declare function loadJSONFixtures(...uls: string[]): jasmine.JSONFixtures;
declare function getJSONFixture(url: string): any;
declare function spyOnEvent(selector: string, eventName: string): jasmine.JQueryEventSpy;
declare module jasmine {
function spiedEventsKey(selector: JQuery, eventName: string): string;
@@ -30,6 +35,7 @@ declare module jasmine {
interface Fixtures {
fixturesPath: string;
containerId: string;
set(html: string): string;
appendSet(html: string);
preload(...uls: string[]);
@@ -38,16 +44,17 @@ declare module jasmine {
read(...uls: string[]): string;
clearCache();
cleanUp();
sandbox(attributes): JQuery;
sandbox(attributes?: any): string;
createContainer_(html: string);
addToContainer_(html: string);
getFixtureHtml_(url: string): string;
loadFixtureIntoCache_(relativeUrl: string);
makeFixtureUrl_(relativeUrl: string): string;
proxyCallTo_(methodName, passedArguments): any;
proxyCallTo_(methodName: string, passedArguments): any;
}
interface StyleFixtures {
fixturesPath: string;
set(html: string): string;
appendSet(html: string);
preload(...uls: string[]);
@@ -60,22 +67,19 @@ declare module jasmine {
getFixtureHtml_(url: string): string;
loadFixtureIntoCache_(relativeUrl: string);
makeFixtureUrl_(relativeUrl: string): string;
proxyCallTo_(methodName, passedArguments): any;
proxyCallTo_(methodName: string, passedArguments): any;
}
interface JSONFixtures {
fixturesPath: string;
load(...uls: string[]);
read(...uls: string[]): string;
clearCache();
getFixtureData_(url: string): any;
loadFixtureIntoCache_(relativeUrl: string);
proxyCallTo_(methodName, passedArguments): any;
proxyCallTo_(methodName: string, passedArguments): any;
}
var Fixtures: Fixtures;
var StyleFixtures: StyleFixtures;
var JSONFixtures: JSONFixtures;
interface Matchers {
toHaveClass(className: string): boolean;
toHaveCss(css): boolean;
@@ -97,25 +101,43 @@ declare module jasmine {
toHaveData(key, expectedValue): boolean;
toBe(selector: JQuery): boolean;
toContain(selector: JQuery): boolean;
toBeMatchedBy(selector: JQuery): boolean;
toBeDisabled(selector: JQuery): boolean;
toBeFocused(selector: JQuery): boolean;
toBeMatchedBy(selector: string): boolean;
toBeDisabled(): boolean;
toBeFocused(): boolean;
toHandle(event): boolean;
toHandleWith(eventName: string, eventHandler): boolean;
toHaveBeenTriggeredOn(selector: JQuery): boolean;
toHaveBeenTriggered(): boolean;
toHaveBeenTriggeredOnAndWith(...args: any[]): boolean;
toHaveBeenPreventedOn(selector: JQuery): boolean;
toHaveBeenTriggeredOn(selector: string): boolean;
toHaveBeenTriggeredOnAndWith(selector: string, ...args: any[]): boolean;
toHaveBeenPrevented(): boolean;
toHaveBeenStoppedOn(selector: JQuery): boolean;
toHaveBeenPreventedOn(selector: string): boolean;
toHaveBeenStopped(): boolean;
toHaveBeenStoppedOn(selector: string): boolean;
}
interface JQueryEventSpy {
selector: string;
eventName: string;
handler(eventObject: JQueryEventObject): any;
reset(): any;
}
interface JasmineJQuery {
browserTagCaseIndependentHtml(html: string): string;
elementToString(element: JQuery): string;
matchersClass: any;
events: JasmineJQueryEvents;
}
interface JasmineJQueryEvents {
spyOn(selector: string, eventName: string): JQueryEventSpy;
args(selector: string, eventName: string): any;
wasTriggered(selector: string, eventName: string): boolean;
wasTriggeredWith(selector: string, eventName: string, expectedArgs: any, env: jasmine.Env): boolean;
wasPrevented(selector: string, eventName: string): boolean;
wasStopped(selector: string, eventName: string): boolean;
cleanUp();
}
var JQuery: JasmineJQuery;
+230 -166
View File
@@ -4,15 +4,15 @@
// DefinitelyTyped: https://github.com/borisyankov/DefinitelyTyped
declare function describe(description: string, specDefinitions: Function): void;
declare function xdescribe(description: string, specDefinitions: Function): void;
declare function describe(description: string, specDefinitions: () => void): void;
declare function xdescribe(description: string, specDefinitions: () => void): void;
declare function it(expectation: string, assertion: () => void ): void;
declare function it(expectation: string, assertion: (done: (err?:any) => void) => void ): void;
declare function xit(expectation: string, assertion: Function): void;
declare function it(expectation: string, assertion: () => void): void;
declare function it(expectation: string, assertion: (done: (err?: any) => void) => void): void;
declare function xit(expectation: string, assertion: () => void): void;
declare function beforeEach(action: Function): void;
declare function afterEach(action: Function): void;
declare function beforeEach(action: () => void): void;
declare function afterEach(action: () => void): void;
declare function expect(spy: Function): jasmine.Matchers;
//declare function expect(spy: jasmine.Spy): jasmine.Matchers;
@@ -28,7 +28,7 @@ declare module jasmine {
var Clock: Clock;
function any(aclass: any):any;
function any(aclass: any): Any;
function objectContaining(sample: any): ObjectContaining;
function createSpy(name: string, originalFn?: Function): Spy;
function createSpyObj(baseName: string, methodNames: any[]): any;
@@ -37,123 +37,173 @@ declare module jasmine {
interface Any {
new (expectedClass:any):any;
new (expectedClass: any): any;
jasmineMatches(other:any):any;
jasmineToString():any;
jasmineMatches(other: any): boolean;
jasmineToString(): string;
}
interface ObjectContaining {
new (sample: any): any;
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): any;
jasmineToString(): any;
jasmineMatches(other: any, mismatchKeys: any[], mismatchValues: any[]): boolean;
jasmineToString(): string;
}
interface Block {
new (env: Env, func: Function, spec: Spec):any;
new (env: Env, func: SpecFunction, spec: Spec): any;
execute(onComplete:any):any;
execute(onComplete: () => void): void;
}
interface WaitsBlock extends Block {
new (env: Env, timeout: number, spec: Spec): any;
}
interface WaitsForBlock extends Block {
new (env: Env, timeout: number, latchFunction: SpecFunction, message: string, spec: Spec): any;
}
interface Clock {
reset(): void;
tick(millis:any): void;
runFunctionsWithinRange(oldMillis:any, nowMillis:any): void;
scheduleFunction(timeoutKey:any, funcToCall:any, millis:any, recurring:any): void;
tick(millis: number): void;
runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
useMock(): void;
installMock(): void;
uninstallMock(): void;
real:any;
real: void;
assertInstalled(): void;
isInstalled(): boolean;
installed: any;
}
interface Env {
setTimeout:any;
clearTimeout:any;
setInterval:any;
clearInterval:any;
updateInterval:any;
setTimeout: any;
clearTimeout: void;
setInterval: any;
clearInterval: void;
updateInterval: number;
currentSpec: Spec;
version():any;
matchersClass: Matchers;
version(): any;
versionString(): string;
nextSpecId(): number;
addReporter(reporter:any):any;
execute():any;
describe(description:any, specDefinitions:any):any;
beforeEach(beforeEachFunction:any):any;
currentRunner():any;
afterEach(afterEachFunction:any):any;
xdescribe(desc:any, specDefinitions:any):any;
it(description:any, func:any):any;
xit(desc:any, func:any):any;
compareObjects_(a:any, b:any, mismatchKeys:any, mismatchValues:any):any;
equals_(a:any, b:any, mismatchKeys:any, mismatchValues:any):any;
contains_(haystack:any, needle:any):any;
addEqualityTester(equalityTester:any):any;
specFilter(spec:any): boolean;
addReporter(reporter: Reporter): void;
execute(): void;
describe(description: string, specDefinitions: () => void): Suite;
beforeEach(beforeEachFunction: () => void): void;
currentRunner(): Runner;
afterEach(afterEachFunction: () => void): void;
xdescribe(desc: string, specDefinitions: () => void): XSuite;
it(description: string, func: () => void): Spec;
xit(desc: string, func: () => void): XSpec;
compareRegExps_(a: RegExp, b: RegExp, mismatchKeys: string[], mismatchValues: string[]): boolean;
compareObjects_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
equals_(a: any, b: any, mismatchKeys: string[], mismatchValues: string[]): boolean;
contains_(haystack: any, needle: any): boolean;
addEqualityTester(equalityTester: (a: any, b: any, env: Env, mismatchKeys: string[], mismatchValues: string[]) => boolean): void;
specFilter(spec: Spec): boolean;
}
interface FakeTimer {
new ():any;
new (): any;
reset(): void;
tick(millis:any): void;
runFunctionsWithinRange(oldMillis:any, nowMillis:any): void;
scheduleFunction(timeoutKey:any, funcToCall:any, millis:any, recurring:any): void;
tick(millis: number): void;
runFunctionsWithinRange(oldMillis: number, nowMillis: number): void;
scheduleFunction(timeoutKey: any, funcToCall: () => void, millis: number, recurring: boolean): void;
}
interface HtmlReporter {
new ():any;
new (): any;
}
interface NestedResults {
new ():any;
rollupCounts(result:any):any;
log(values:any):any;
getItems():any;
addResult(result:any):any;
passed():any;
interface Result {
type: string;
}
interface NestedResults extends Result {
description: string;
totalCount: number;
passedCount: number;
failedCount: number;
skipped: boolean;
rollupCounts(result: NestedResults): void;
log(values: any): void;
getItems(): Result[];
addResult(result: Result): void;
passed(): boolean;
}
interface MessageResult extends Result {
values: any;
trace: Trace;
}
interface ExpectationResult extends Result {
matcherName: string;
passed(): boolean;
expected: any;
actual: any;
message: string;
trace: Trace;
}
interface Trace {
name: string;
message: string;
stack: any;
}
interface PrettyPrinter {
new ():any;
new (): any;
format(value:any):any;
iterateObject(obj:any, fn:any):any;
emitScalar(value:any):any;
emitString(value:any):any;
emitArray(array:any):any;
emitObject(obj:any):any;
append(value:any):any;
format(value: any): void;
iterateObject(obj: any, fn: (property: string, isGetter: boolean) => void): void;
emitScalar(value: any): void;
emitString(value: string): void;
emitArray(array: any[]): void;
emitObject(obj: any): void;
append(value: any): void;
}
interface StringPrettyPrinter extends PrettyPrinter {
}
interface Queue {
new (env:any):any;
new (env: any): any;
addBefore(block:any, ensure:any):any;
add(block:any, ensure:any):any;
insertNext(block:any, ensure:any):any;
start(onComplete:any):any;
isRunning():any;
next_():any;
results():any;
env: Env;
ensured: boolean[];
blocks: Block[];
running: boolean;
index: number;
offset: number;
abort: boolean;
addBefore(block: Block, ensure?: boolean): void;
add(block: any, ensure?: boolean): void;
insertNext(block: any, ensure?: boolean): void;
start(onComplete?: () => void): void;
isRunning(): boolean;
next_(): void;
results(): NestedResults;
}
interface Matchers {
new (env: Env, actual:any, spec: Env, isNot?: boolean):any;
new (env: Env, actual: any, spec: Env, isNot?: boolean): any;
env: Env;
actual: any;
@@ -161,12 +211,12 @@ declare module jasmine {
isNot?: boolean;
message(): any;
toBe(expected:any): boolean;
toNotBe(expected:any): boolean;
toEqual(expected:any): boolean;
toNotEqual(expected:any): boolean;
toMatch(expected:any): boolean;
toNotMatch(expected:any): boolean;
toBe(expected: any): boolean;
toNotBe(expected: any): boolean;
toEqual(expected: any): boolean;
toNotEqual(expected: any): boolean;
toMatch(expected: any): boolean;
toNotMatch(expected: any): boolean;
toBeDefined(): boolean;
toBeUndefined(): boolean;
toBeNull(): boolean;
@@ -176,86 +226,118 @@ declare module jasmine {
toHaveBeenCalled(): boolean;
wasNotCalled(): boolean;
toHaveBeenCalledWith(...params: any[]): boolean;
toContain(expected:any): boolean;
toNotContain(expected:any): boolean;
toBeLessThan(expected:any): boolean;
toBeGreaterThan(expected:any): boolean;
toBeCloseTo(expected:any, precision:any): boolean;
toContain(expected: any): boolean;
toNotContain(expected: any): boolean;
toBeLessThan(expected: any): boolean;
toBeGreaterThan(expected: any): boolean;
toBeCloseTo(expected: any, precision: any): boolean;
toContainHtml(expected: string): boolean;
toContainText(expected: string): boolean;
toThrow(expected?:any ): boolean;
toThrow(expected?: any): boolean;
not: Matchers;
Any: Any;
}
interface MultiReporter {
new ():any;
addReporter(reporter: Reporter):any;
interface Reporter {
reportRunnerStarting(runner: Runner): void;
reportRunnerResults(runner: Runner): void;
reportSuiteResults(suite: Suite): void;
reportSpecStarting(spec: Spec): void;
reportSpecResults(spec: Spec): void;
log(str: string): void;
}
interface Reporter {
reportRunnerStarting(runner:any):any;
reportRunnerResults(runner:any):any;
reportSuiteResults(suite:any):any;
reportSpecStarting(spec:any):any;
reportSpecResults(spec:any):any;
log(str:any):any;
interface MultiReporter extends Reporter {
addReporter(reporter: Reporter): void;
}
interface Runner {
new (env: Env):any;
new (env: Env): any;
execute():any;
beforeEach(beforeEachFunction:any):any;
afterEach(afterEachFunction:any):any;
finishCallback():any;
addSuite(suite:any):any;
add(block:any):any;
specs():any;
suites():any;
topLevelSuites():any;
results():any;
execute(): void;
beforeEach(beforeEachFunction: SpecFunction): void;
afterEach(afterEachFunction: SpecFunction): void;
finishCallback(): void;
addSuite(suite: Suite): void;
add(block: Block): void;
specs(): Spec[];
suites(): Suite[];
topLevelSuites(): Suite[];
results(): NestedResults;
}
interface Spec {
new (env: Env, suite: Suite, description: string):any;
interface SpecFunction {
(spec?: Spec): void
}
interface SuiteOrSpec {
id: number;
env: Env;
suite: Suite;
description: string;
queue: Queue;
}
interface Spec extends SuiteOrSpec {
new (env: Env, suite: Suite, description: string): any;
suite: Suite;
afterCallbacks: any;
spies_: any;
afterCallbacks: SpecFunction[];
spies_: Spy[];
results_: NestedResults;
matchersClass: any;
matchersClass: Matchers;
getFullName(): string;
results():any;
log():any;
runs(func: Function):any;
addToQueue(block:any):any;
addMatcherResult(result:any):any;
expect(actual:any):any;
waitsFor(latchFunction: Function, timeoutMessage?: string, timeout?: number):any;
fail(e:any):any;
getMatchersClass_():any;
addMatchers(matchersPrototype:any):any;
finishCallback():any;
finish(onComplete:any):any;
after(doAfter:any):any;
execute(onComplete:any):any;
addBeforesAndAftersToQueue():any;
explodes():any;
spyOn(obj:any, methodName:any, ignoreMethodDoesntExist:any):any;
removeAllSpies():any;
results(): NestedResults;
log(arguments): any;
runs(func: SpecFunction): Spec;
addToQueue(block: Block): void;
addMatcherResult(result: Result): void;
expect(actual: any): any;
waits(timeout: number): Spec;
waitsFor(latchFunction: SpecFunction, timeoutMessage?: string, timeout?: number): Spec;
fail(e?: any): void;
getMatchersClass_(): Matchers;
addMatchers(matchersPrototype: any): void;
finishCallback(): void;
finish(onComplete?: () => void): void;
after(doAfter: SpecFunction): void;
execute(onComplete?: () => void): any;
addBeforesAndAftersToQueue(): void;
explodes(): void;
spyOn(obj: any, methodName: string, ignoreMethodDoesntExist: boolean): Spy;
removeAllSpies(): void;
}
interface XSpec {
id: number;
runs(): void;
}
interface Suite extends SuiteOrSpec {
new (env: Env, description: string, specDefinitions: () => void, parentSuite: Suite): any;
parentSuite: Suite;
getFullName(): string;
finish(onComplete?: () => void): void;
beforeEach(beforeEachFunction: SpecFunction): void;
afterEach(afterEachFunction: SpecFunction): void;
results(): NestedResults;
add(suiteOrSpec: SuiteOrSpec): void;
specs(): Spec[];
suites(): Suite[];
children(): any[];
execute(onComplete?: () => void): void;
}
interface XSuite {
execute(): void;
}
interface Spy {
@@ -268,53 +350,35 @@ declare module jasmine {
wasCalled: boolean;
callCount: number;
andReturn(value:any): Spy;
andReturn(value: any): Spy;
andCallThrough(): Spy;
andCallFake(fakeFunc: Function): Spy;
}
interface Suite {
new (env: Env, description: string, specDefinitions: Function, parentSuite: Suite):any;
getFullName():any;
finish(onComplete:any):any;
beforeEach(beforeEachFunction:any):any;
afterEach(afterEachFunction:any):any;
results():any;
add(suiteOrSpec:any):any;
specs():any;
suites():any;
children():any;
execute(onComplete:any):any;
}
interface Util {
inherit(childClass: Function, parentClass: Function):any;
formatException(e:any):any;
inherit(childClass: Function, parentClass: Function): any;
formatException(e: any): any;
htmlEscape(str: string): string;
argsToArray(args:any):any;
extend(destination:any, source:any):any;
argsToArray(args: any): any;
extend(destination: any, source: any): any;
}
interface JsApiReporter {
interface JsApiReporter extends Reporter {
result:any;
messages:any;
started: boolean;
finished: boolean;
result: any;
messages: any;
new ():any;
new (): any;
reportRunnerStarting(runner:any):any;
suites():any;
summarize_(suiteOrSpec:any):any;
results():any;
resultsForSpec(specId:any):any;
reportRunnerResults(runner:any):any;
reportSuiteResults(suite:any):any;
reportSpecResults(spec:any):any;
log(str:any):any;
resultsForSpecs(specIds:any):any;
summarizeResult_(result:any):any;
suites(): Suite[];
summarize_(suiteOrSpec: SuiteOrSpec): any;
results(): any;
resultsForSpec(specId: any): any;
log(str: any): any;
resultsForSpecs(specIds: any): any;
summarizeResult_(result: any): any;
}
interface Jasmine {
+3 -1
View File
@@ -1124,7 +1124,9 @@ function test_error() {
$(this).hide();
})
.attr("src", "missing.png");
jQuery.error = console.error;
jQuery.error = (message?: string) => {
console.error(message); return this;
}
}
function test_eventParams() {