Matteo Scandolo | fc4b37b | 2017-02-02 12:18:47 -0800 | [diff] [blame] | 1 | // Generated by typings |
| 2 | // Source: https://raw.githubusercontent.com/DefinitelyTyped/DefinitelyTyped/cd4debea25a280da0808d4ff2ca5a4bdb34bd28b/jasmine-jquery/index.d.ts |
| 3 | declare function sandbox(attributes?: any): string; |
| 4 | |
| 5 | declare function readFixtures(...uls: string[]): string; |
| 6 | declare function preloadFixtures(...uls: string[]) : void; |
| 7 | declare function loadFixtures(...uls: string[]): void; |
| 8 | declare function appendLoadFixtures(...uls: string[]): void; |
| 9 | declare function setFixtures(html: string): string; |
| 10 | declare function appendSetFixtures(html: string) : void; |
| 11 | |
| 12 | declare function preloadStyleFixtures(...uls: string[]) : void; |
| 13 | declare function loadStyleFixtures(...uls: string[]) : void; |
| 14 | declare function appendLoadStyleFixtures(...uls: string[]) : void; |
| 15 | declare function setStyleFixtures(html: string) : void; |
| 16 | declare function appendSetStyleFixtures(html: string) : void; |
| 17 | |
| 18 | declare function loadJSONFixtures(...uls: string[]): jasmine.JSONFixtures; |
| 19 | declare function getJSONFixture(url: string): any; |
| 20 | |
| 21 | declare function spyOnEvent(selector: string, eventName: string): jasmine.JQueryEventSpy; |
| 22 | |
| 23 | declare namespace jasmine { |
| 24 | function spiedEventsKey(selector: JQuery, eventName: string): string; |
| 25 | |
| 26 | function getFixtures(): Fixtures; |
| 27 | function getStyleFixtures(): StyleFixtures; |
| 28 | function getJSONFixtures(): JSONFixtures; |
| 29 | |
| 30 | interface Fixtures { |
| 31 | fixturesPath: string; |
| 32 | containerId: string; |
| 33 | set(html: string): string; |
| 34 | appendSet(html: string): void; |
| 35 | preload(...uls: string[]): void; |
| 36 | load(...uls: string[]): void; |
| 37 | appendLoad(...uls: string[]): void; |
| 38 | read(...uls: string[]): string; |
| 39 | clearCache(): void; |
| 40 | cleanUp(): void; |
| 41 | sandbox(attributes?: any): string; |
| 42 | createContainer_(html: string) : string; |
| 43 | addToContainer_(html: string): void; |
| 44 | getFixtureHtml_(url: string): string; |
| 45 | loadFixtureIntoCache_(relativeUrl: string): void; |
| 46 | makeFixtureUrl_(relativeUrl: string): string; |
| 47 | proxyCallTo_(methodName: string, passedArguments: any): any; |
| 48 | } |
| 49 | |
| 50 | interface StyleFixtures { |
| 51 | fixturesPath: string; |
| 52 | set(html: string): string; |
| 53 | appendSet(html: string): void; |
| 54 | preload(...uls: string[]) : void; |
| 55 | load(...uls: string[]) : void; |
| 56 | appendLoad(...uls: string[]) : void; |
| 57 | read_(...uls: string[]): string; |
| 58 | clearCache() : void; |
| 59 | cleanUp() : void; |
| 60 | createStyle_(html: string) : void; |
| 61 | getFixtureHtml_(url: string): string; |
| 62 | loadFixtureIntoCache_(relativeUrl: string) : void; |
| 63 | makeFixtureUrl_(relativeUrl: string): string; |
| 64 | proxyCallTo_(methodName: string, passedArguments: any): any; |
| 65 | } |
| 66 | |
| 67 | interface JSONFixtures { |
| 68 | fixturesPath: string; |
| 69 | load(...uls: string[]): void; |
| 70 | read(...uls: string[]): string; |
| 71 | clearCache(): void; |
| 72 | getFixtureData_(url: string): any; |
| 73 | loadFixtureIntoCache_(relativeUrl: string): void; |
| 74 | proxyCallTo_(methodName: string, passedArguments: any): any; |
| 75 | } |
| 76 | |
| 77 | interface Matchers { |
| 78 | /** |
| 79 | * Check if DOM element has class. |
| 80 | * |
| 81 | * @param className Name of the class to check. |
| 82 | * |
| 83 | * @example |
| 84 | * // returns true |
| 85 | * expect($('<div class="some-class"></div>')).toHaveClass("some-class") |
| 86 | */ |
| 87 | toHaveClass(className: string): boolean; |
| 88 | |
| 89 | /** |
| 90 | * Check if DOM element has the given CSS properties. |
| 91 | * |
| 92 | * @param css Object containing the properties (and values) to check. |
| 93 | * |
| 94 | * @example |
| 95 | * // returns true |
| 96 | * expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({display: "none", margin: "10px"}) |
| 97 | * |
| 98 | * @example |
| 99 | * // returns true |
| 100 | * expect($('<div style="display: none; margin: 10px;"></div>')).toHaveCss({margin: "10px"}) |
| 101 | */ |
| 102 | toHaveCss(css: any): boolean; |
| 103 | |
| 104 | /** |
| 105 | * Checks if DOM element is visible. |
| 106 | * Elements are considered visible if they consume space in the document. Visible elements have a width or height that is greater than zero. |
| 107 | */ |
| 108 | toBeVisible(): boolean; |
| 109 | /** |
| 110 | * Check if DOM element is hidden. |
| 111 | * Elements can be hidden for several reasons: |
| 112 | * - They have a CSS display value of none ; |
| 113 | * - They are form elements with type equal to hidden. |
| 114 | * - Their width and height are explicitly set to 0. |
| 115 | * - An ancestor element is hidden, so the element is not shown on the page. |
| 116 | */ |
| 117 | toBeHidden(): boolean; |
| 118 | |
| 119 | /** |
| 120 | * Only for tags that have checked attribute |
| 121 | * |
| 122 | * @example |
| 123 | * // returns true |
| 124 | * expect($('<option selected="selected"></option>')).toBeSelected() |
| 125 | */ |
| 126 | toBeSelected(): boolean; |
| 127 | |
| 128 | /** |
| 129 | * Only for tags that have checked attribute |
| 130 | * @example |
| 131 | * // returns true |
| 132 | * expect($('<input type="checkbox" checked="checked"/>')).toBeChecked() |
| 133 | */ |
| 134 | toBeChecked(): boolean; |
| 135 | |
| 136 | /** |
| 137 | * Checks for child DOM elements or text |
| 138 | */ |
| 139 | toBeEmpty(): boolean; |
| 140 | |
| 141 | /** |
| 142 | * Checks if element exists in or out the DOM. |
| 143 | */ |
| 144 | toExist(): boolean; |
| 145 | |
| 146 | /** |
| 147 | * Checks if array has the given length. |
| 148 | * |
| 149 | * @param length Expected length |
| 150 | */ |
| 151 | toHaveLength(length: number): boolean; |
| 152 | |
| 153 | /** |
| 154 | * Check if DOM element contains an attribute and, optionally, if the value of the attribute is equal to the expected one. |
| 155 | * |
| 156 | * @param attributeName Name of the attribute to check |
| 157 | * @param expectedAttributeValue Expected attribute value |
| 158 | */ |
| 159 | toHaveAttr(attributeName: string, expectedAttributeValue? : any): boolean; |
| 160 | |
| 161 | /** |
| 162 | * Check if DOM element contains a property and, optionally, if the value of the property is equal to the expected one. |
| 163 | * |
| 164 | * @param propertyName Property name to check |
| 165 | * @param expectedPropertyValue Expected property value |
| 166 | */ |
| 167 | toHaveProp(propertyName: string, expectedPropertyValue? : any): boolean; |
| 168 | |
| 169 | /** |
| 170 | * Check if DOM element has the given Id |
| 171 | * |
| 172 | * @param Id Expected identifier |
| 173 | */ |
| 174 | toHaveId(id: string): boolean; |
| 175 | |
| 176 | /** |
| 177 | * Check if DOM element has the specified HTML. |
| 178 | * |
| 179 | * @example |
| 180 | * // returns true |
| 181 | * expect($('<div><span></span></div>')).toHaveHtml('<span></span>') |
| 182 | */ |
| 183 | toHaveHtml(html: string): boolean; |
| 184 | |
| 185 | /** |
| 186 | * Check if DOM element contains the specified HTML. |
| 187 | * |
| 188 | * @example |
| 189 | * // returns true |
| 190 | * expect($('<div><ul></ul><h1>header</h1></div>')).toContainHtml('<ul></ul>') |
| 191 | */ |
| 192 | toContainHtml(html: string): boolean; |
| 193 | |
| 194 | /** |
| 195 | * Check if DOM element has the given Text. |
| 196 | * @param text Accepts a string or regular expression |
| 197 | * |
| 198 | * @example |
| 199 | * // returns true |
| 200 | * expect($('<div>some text</div>')).toHaveText('some text') |
| 201 | */ |
| 202 | toHaveText(text: string): boolean; |
| 203 | /** |
| 204 | * Check if DOM element contains the specified text. |
| 205 | * |
| 206 | * @example |
| 207 | * // returns true |
| 208 | * expect($('<div><ul></ul><h1>header</h1></div>')).toContainText('header') |
| 209 | */ |
| 210 | toContainText(text: string): boolean; |
| 211 | |
| 212 | /** |
| 213 | * Check if DOM element has the given value. |
| 214 | * This can only be applied for element on with jQuery val() can be called. |
| 215 | * |
| 216 | * @example |
| 217 | * // returns true |
| 218 | * expect($('<input type="text" value="some text"/>')).toHaveValue('some text') |
| 219 | */ |
| 220 | toHaveValue(value : string): boolean; |
| 221 | |
| 222 | /** |
| 223 | * Check if DOM element has the given data. |
| 224 | * This can only be applied for element on with jQuery data(key) can be called. |
| 225 | * |
| 226 | */ |
| 227 | toHaveData(key : string, expectedValue : string): boolean; |
| 228 | toBe(selector: JQuery): boolean; |
| 229 | |
| 230 | /** |
| 231 | * Check if DOM element is matched by the given selector. |
| 232 | * |
| 233 | * @example |
| 234 | * // returns true |
| 235 | * expect($('<div><span class="some-class"></span></div>')).toContain('some-class') |
| 236 | */ |
| 237 | toContain(selector: JQuery): boolean; |
| 238 | |
| 239 | /** |
| 240 | * Check if DOM element exists inside the given parent element. |
| 241 | * |
| 242 | * @example |
| 243 | * // returns true |
| 244 | * expect($('<div><span class="some-class"></span></div>')).toContainElement('span.some-class') |
| 245 | */ |
| 246 | toContainElement(selector: string): boolean; |
| 247 | |
| 248 | /** |
| 249 | * Check to see if the set of matched elements matches the given selector |
| 250 | * |
| 251 | * @example |
| 252 | * expect($('<span></span>').addClass('js-something')).toBeMatchedBy('.js-something') |
| 253 | * |
| 254 | * @returns {Boolean} true if DOM contains the element |
| 255 | */ |
| 256 | toBeMatchedBy(selector: string): boolean; |
| 257 | |
| 258 | /** |
| 259 | * Only for tags that have disabled attribute |
| 260 | * @example |
| 261 | * // returns true |
| 262 | * expect('<input type="submit" disabled="disabled"/>').toBeDisabled() |
| 263 | */ |
| 264 | toBeDisabled(): boolean; |
| 265 | |
| 266 | /** |
| 267 | * Check if DOM element is focused |
| 268 | * @example |
| 269 | * // returns true |
| 270 | * expect($('<input type="text" />').focus()).toBeFocused() |
| 271 | */ |
| 272 | toBeFocused(): boolean; |
| 273 | |
| 274 | /** |
| 275 | * Checks if DOM element handles event. |
| 276 | * |
| 277 | * @example |
| 278 | * // returns true |
| 279 | * expect($form).toHandle("submit") |
| 280 | */ |
| 281 | toHandle(eventName: string): boolean; |
| 282 | |
| 283 | /** |
| 284 | * Assigns a callback to an event of the DOM element. |
| 285 | * |
| 286 | * @param eventName Name of the event to assign the callback to. |
| 287 | * @param eventHandler Callback function to be assigned. |
| 288 | * |
| 289 | * @example |
| 290 | * expect($form).toHandleWith("submit", yourSubmitCallback) |
| 291 | */ |
| 292 | toHandleWith(eventName: string, eventHandler : JQueryCallback): boolean; |
| 293 | |
| 294 | /** |
| 295 | * Checks if event was triggered. |
| 296 | */ |
| 297 | toHaveBeenTriggered(): boolean; |
| 298 | |
| 299 | /** |
| 300 | * Checks if the event has been triggered on selector. |
| 301 | * @param selector Selector that should have triggered the event. |
| 302 | */ |
| 303 | toHaveBeenTriggeredOn(selector: string): boolean; |
| 304 | |
| 305 | /** |
| 306 | * Checks if the event has been triggered on selector. |
| 307 | * @param selector Selector that should have triggered the event. |
| 308 | * @param args Extra arguments to be passed to jQuery events functions. |
| 309 | */ |
| 310 | toHaveBeenTriggeredOnAndWith(selector: string, ...args: any[]): boolean; |
| 311 | |
| 312 | /** |
| 313 | * Checks if event propagation has been prevented. |
| 314 | */ |
| 315 | toHaveBeenPrevented(): boolean; |
| 316 | |
| 317 | /** |
| 318 | * Checks if event propagation has been prevented on element with selector. |
| 319 | * |
| 320 | * @param selector Selector that should have prevented the event. |
| 321 | */ |
| 322 | toHaveBeenPreventedOn(selector: string): boolean; |
| 323 | |
| 324 | /** |
| 325 | * Checks if event propagation has been stopped. |
| 326 | * |
| 327 | * @example |
| 328 | * // returns true |
| 329 | * var spyEvent = spyOnEvent('#some_element', 'click') |
| 330 | * $('#some_element').click(function (event){event.stopPropagation();}) |
| 331 | * $('#some_element').click() |
| 332 | * expect(spyEvent).toHaveBeenStopped() |
| 333 | */ |
| 334 | toHaveBeenStopped(): boolean; |
| 335 | |
| 336 | /** |
| 337 | * Checks if event propagation has been stopped by an element with the given selector. |
| 338 | * @param selector Selector of the element that should have stopped the event propagation. |
| 339 | * |
| 340 | * @example |
| 341 | * // returns true |
| 342 | * $('#some_element').click(function (event){event.stopPropagation();}) |
| 343 | * $('#some_element').click() |
| 344 | * expect('click').toHaveBeenStoppedOn('#some_element') |
| 345 | */ |
| 346 | toHaveBeenStoppedOn(selector: string): boolean; |
| 347 | |
| 348 | /** |
| 349 | * Checks to see if the matched element is attached to the DOM. |
| 350 | * @example |
| 351 | * expect($('#id-name')[0]).toBeInDOM() |
| 352 | */ |
| 353 | toBeInDOM(): boolean; |
| 354 | |
| 355 | } |
| 356 | |
| 357 | interface JQueryEventSpy { |
| 358 | selector: string; |
| 359 | eventName: string; |
| 360 | handler(eventObject: JQueryEventObject): any; |
| 361 | reset(): any; |
| 362 | } |
| 363 | |
| 364 | interface JasmineJQuery { |
| 365 | browserTagCaseIndependentHtml(html: string): string; |
| 366 | elementToString(element: JQuery): string; |
| 367 | matchersClass: any; |
| 368 | events: JasmineJQueryEvents; |
| 369 | } |
| 370 | |
| 371 | interface JasmineJQueryEvents { |
| 372 | spyOn(selector: string, eventName: string): JQueryEventSpy; |
| 373 | args(selector: string, eventName: string): any; |
| 374 | wasTriggered(selector: string, eventName: string): boolean; |
| 375 | wasTriggeredWith(selector: string, eventName: string, expectedArgs: any, env: jasmine.Env): boolean; |
| 376 | wasPrevented(selector: string, eventName: string): boolean; |
| 377 | wasStopped(selector: string, eventName: string): boolean; |
| 378 | cleanUp() : void; |
| 379 | } |
| 380 | |
| 381 | var JQuery: JasmineJQuery; |
| 382 | } |