|
| 1 | +declare const expectCookies: expectCookies.ExpectCookiesStatic; |
| 2 | + |
| 3 | +declare namespace expectCookies { |
| 4 | + interface Assertion { |
| 5 | + set(expects: SetMatcher | ReadonlyArray<SetMatcher>, assert?: boolean): this; |
| 6 | + |
| 7 | + reset(expects: ResetMatcher | ReadonlyArray<ResetMatcher>, assert?: boolean): this; |
| 8 | + |
| 9 | + "new"(expects: ResetMatcher | ReadonlyArray<ResetMatcher>, assert?: boolean): this; |
| 10 | + |
| 11 | + renew(expects: RenewMatcher | ReadonlyArray<RenewMatcher>, assert?: boolean): this; |
| 12 | + |
| 13 | + contain(expects: ContainMatcher | ReadonlyArray<ContainMatcher>, assert?: boolean): this; |
| 14 | + |
| 15 | + not<M extends keyof Omit<Assertion, "not">>( |
| 16 | + method: M, |
| 17 | + expects: AssertionMatchers[M] | ReadonlyArray<AssertionMatchers[M]>, |
| 18 | + ): this; |
| 19 | + } |
| 20 | + |
| 21 | + type CustomAssertion = ( |
| 22 | + req: { cookies: CustomAssertionCookie[] }, |
| 23 | + res: { cookies: CustomAssertionCookie[] }, |
| 24 | + ) => boolean; |
| 25 | + |
| 26 | + interface CustomAssertionCookie { |
| 27 | + name: string; |
| 28 | + value: string; |
| 29 | + options?: Record<string, string | boolean>; |
| 30 | + } |
| 31 | + |
| 32 | + interface AssertionMatchers { |
| 33 | + readonly set: SetMatcher; |
| 34 | + readonly reset: ResetMatcher; |
| 35 | + readonly new: NewMatcher; |
| 36 | + readonly renew: RenewMatcher; |
| 37 | + readonly contain: ContainMatcher; |
| 38 | + } |
| 39 | + |
| 40 | + interface SetMatcher { |
| 41 | + readonly name: string; |
| 42 | + readonly options?: Record<string, string | boolean>; |
| 43 | + } |
| 44 | + |
| 45 | + interface ResetMatcher { |
| 46 | + readonly name: string; |
| 47 | + } |
| 48 | + |
| 49 | + type NewMatcher = ResetMatcher; |
| 50 | + |
| 51 | + interface RenewMatcher { |
| 52 | + readonly name: string; |
| 53 | + |
| 54 | + readonly options: |
| 55 | + | { "max-age": number; expires?: never } |
| 56 | + | { expires: Date; "max-age"?: never }; |
| 57 | + } |
| 58 | + |
| 59 | + interface ContainMatcher { |
| 60 | + readonly name: string; |
| 61 | + |
| 62 | + readonly value: string | boolean; |
| 63 | + |
| 64 | + readonly options?: { |
| 65 | + readonly domain?: string; |
| 66 | + readonly path?: string; |
| 67 | + readonly expires?: string; // RFC 6265 sane-cookie-date (e.g. "Fri, 26 Sep 2025 04:26:52 GMT") |
| 68 | + readonly secure?: boolean; |
| 69 | + readonly httponly?: boolean; |
| 70 | + readonly "max-age"?: string; |
| 71 | + }; |
| 72 | + } |
| 73 | + |
| 74 | + interface ExpectCookiesStatic extends Assertion { |
| 75 | + ( |
| 76 | + secret?: string | ReadonlyArray<string> | null, |
| 77 | + asserts?: CustomAssertion | ReadonlyArray<CustomAssertion>, |
| 78 | + ): Assertion; |
| 79 | + } |
| 80 | +} |
| 81 | + |
| 82 | +export = expectCookies; |
0 commit comments