|
| 1 | +declare function expect(target?: any): Expect.Root; |
| 2 | + |
| 3 | +declare namespace Expect { |
| 4 | + interface Assertion { |
| 5 | + /** |
| 6 | + * Check if the value is truthy |
| 7 | + */ |
| 8 | + ok(): void; |
| 9 | + |
| 10 | + /** |
| 11 | + * Creates an anonymous function which calls fn with arguments. |
| 12 | + */ |
| 13 | + withArgs(...args: any[]): Root; |
| 14 | + |
| 15 | + /** |
| 16 | + * Assert that the function throws. |
| 17 | + * |
| 18 | + * @param fn callback to match error string against |
| 19 | + */ |
| 20 | + throwError(fn?: (exception: any) => void): void; |
| 21 | + |
| 22 | + /** |
| 23 | + * Assert that the function throws. |
| 24 | + * |
| 25 | + * @param fn callback to match error string against |
| 26 | + */ |
| 27 | + throwException(fn?: (exception: any) => void): void; |
| 28 | + |
| 29 | + /** |
| 30 | + * Assert that the function throws. |
| 31 | + * |
| 32 | + * @param regexp regexp to match error string against |
| 33 | + */ |
| 34 | + throwError(regexp: RegExp): void; |
| 35 | + |
| 36 | + /** |
| 37 | + * Assert that the function throws. |
| 38 | + * |
| 39 | + * @param fn callback to match error string against |
| 40 | + */ |
| 41 | + throwException(regexp: RegExp): void; |
| 42 | + |
| 43 | + /** |
| 44 | + * Checks if the array is empty. |
| 45 | + */ |
| 46 | + empty(): Assertion; |
| 47 | + |
| 48 | + /** |
| 49 | + * Checks if the obj exactly equals another. |
| 50 | + */ |
| 51 | + equal(obj: any): Assertion; |
| 52 | + |
| 53 | + /** |
| 54 | + * Checks if the obj sortof equals another. |
| 55 | + */ |
| 56 | + eql(obj: any): Assertion; |
| 57 | + |
| 58 | + /** |
| 59 | + * Assert within start to finish (inclusive). |
| 60 | + * |
| 61 | + * @param start |
| 62 | + * @param finish |
| 63 | + */ |
| 64 | + within(start: number, finish: number): Assertion; |
| 65 | + |
| 66 | + /** |
| 67 | + * Assert typeof. |
| 68 | + */ |
| 69 | + a(type: string): Assertion; |
| 70 | + |
| 71 | + /** |
| 72 | + * Assert instanceof. |
| 73 | + */ |
| 74 | + a(type: Function): Assertion; |
| 75 | + |
| 76 | + /** |
| 77 | + * Assert typeof / instanceof. |
| 78 | + */ |
| 79 | + an: An; |
| 80 | + |
| 81 | + /** |
| 82 | + * Assert numeric value above n. |
| 83 | + */ |
| 84 | + greaterThan(n: number): Assertion; |
| 85 | + |
| 86 | + /** |
| 87 | + * Assert numeric value above n. |
| 88 | + */ |
| 89 | + above(n: number): Assertion; |
| 90 | + |
| 91 | + /** |
| 92 | + * Assert numeric value below n. |
| 93 | + */ |
| 94 | + lessThan(n: number): Assertion; |
| 95 | + |
| 96 | + /** |
| 97 | + * Assert numeric value below n. |
| 98 | + */ |
| 99 | + below(n: number): Assertion; |
| 100 | + |
| 101 | + /** |
| 102 | + * Assert string value matches regexp. |
| 103 | + * |
| 104 | + * @param regexp |
| 105 | + */ |
| 106 | + match(regexp: RegExp): Assertion; |
| 107 | + |
| 108 | + /** |
| 109 | + * Assert property "length" exists and has value of n. |
| 110 | + * |
| 111 | + * @param n |
| 112 | + */ |
| 113 | + length(n: number): Assertion; |
| 114 | + |
| 115 | + /** |
| 116 | + * Assert property name exists, with optional val. |
| 117 | + * |
| 118 | + * @param name |
| 119 | + * @param val |
| 120 | + */ |
| 121 | + property(name: string, val?: any): Assertion; |
| 122 | + |
| 123 | + /** |
| 124 | + * Assert that string contains str. |
| 125 | + */ |
| 126 | + contain(...strings: string[]): Assertion; |
| 127 | + string(str: string): Assertion; |
| 128 | + |
| 129 | + /** |
| 130 | + * Assert that the array contains obj. |
| 131 | + */ |
| 132 | + contain(...objs: any[]): Assertion; |
| 133 | + string(obj: any): Assertion; |
| 134 | + |
| 135 | + /** |
| 136 | + * Assert exact keys or inclusion of keys by using the `.own` modifier. |
| 137 | + */ |
| 138 | + key(keys: string[]): Assertion; |
| 139 | + /** |
| 140 | + * Assert exact keys or inclusion of keys by using the `.own` modifier. |
| 141 | + */ |
| 142 | + key(...keys: string[]): Assertion; |
| 143 | + /** |
| 144 | + * Assert exact keys or inclusion of keys by using the `.own` modifier. |
| 145 | + */ |
| 146 | + keys(keys: string[]): Assertion; |
| 147 | + /** |
| 148 | + * Assert exact keys or inclusion of keys by using the `.own` modifier. |
| 149 | + */ |
| 150 | + keys(...keys: string[]): Assertion; |
| 151 | + |
| 152 | + /** |
| 153 | + * Assert a failure. |
| 154 | + */ |
| 155 | + fail(message?: string): Assertion; |
| 156 | + } |
| 157 | + |
| 158 | + interface Root extends Assertion { |
| 159 | + not: Not; |
| 160 | + to: To; |
| 161 | + only: Only; |
| 162 | + have: Have; |
| 163 | + be: Be; |
| 164 | + } |
| 165 | + |
| 166 | + interface Be extends Assertion { |
| 167 | + /** |
| 168 | + * Checks if the obj exactly equals another. |
| 169 | + */ |
| 170 | + (obj: any): Assertion; |
| 171 | + |
| 172 | + an: An; |
| 173 | + } |
| 174 | + |
| 175 | + interface An extends Assertion { |
| 176 | + /** |
| 177 | + * Assert typeof. |
| 178 | + */ |
| 179 | + (type: string): Assertion; |
| 180 | + |
| 181 | + /** |
| 182 | + * Assert instanceof. |
| 183 | + */ |
| 184 | + (type: Function): Assertion; |
| 185 | + } |
| 186 | + |
| 187 | + interface Not extends Expect.NotBase { |
| 188 | + to: Expect.ToBase; |
| 189 | + } |
| 190 | + |
| 191 | + interface NotBase extends Assertion { |
| 192 | + be: Be; |
| 193 | + have: Have; |
| 194 | + include: Assertion; |
| 195 | + only: Only; |
| 196 | + } |
| 197 | + |
| 198 | + interface To extends Expect.ToBase { |
| 199 | + not: Expect.NotBase; |
| 200 | + } |
| 201 | + |
| 202 | + interface ToBase extends Assertion { |
| 203 | + be: Be; |
| 204 | + have: Have; |
| 205 | + include: Assertion; |
| 206 | + only: Only; |
| 207 | + } |
| 208 | + |
| 209 | + interface Only extends Assertion { |
| 210 | + have: Have; |
| 211 | + } |
| 212 | + |
| 213 | + interface Have extends Assertion { |
| 214 | + own: Assertion; |
| 215 | + } |
| 216 | +} |
| 217 | + |
| 218 | +declare module "expect.js" { |
| 219 | + //@ts-ignore |
| 220 | + export = expect; |
| 221 | +} |
0 commit comments