|
| 1 | +import { expectTypeOf } from "expect-type"; |
| 2 | +import { createHandyClient } from "../src"; |
| 3 | +import { RedisClient } from "redis"; |
| 4 | + |
| 5 | +test("create client with existing client", () => { |
| 6 | + expectTypeOf(createHandyClient).toBeCallableWith({} as RedisClient) |
| 7 | +}) |
| 8 | + |
| 9 | +test("client has promisified redis methods", () => { |
| 10 | + expectTypeOf(createHandyClient) |
| 11 | + .returns.toHaveProperty("get") |
| 12 | + .returns.resolves.toEqualTypeOf<string | null>() |
| 13 | + |
| 14 | + expectTypeOf(createHandyClient) |
| 15 | + .returns.toHaveProperty("set") |
| 16 | + .returns.resolves.toEqualTypeOf<string | null>() |
| 17 | + |
| 18 | + expectTypeOf(createHandyClient) |
| 19 | + .returns.toHaveProperty("geohash") |
| 20 | + .parameters.toEqualTypeOf<[string, ...string[]]>() |
| 21 | + |
| 22 | + expectTypeOf(createHandyClient) |
| 23 | + .returns.toHaveProperty("geohash") |
| 24 | + .returns.resolves.items.toBeString() |
| 25 | + |
| 26 | + expectTypeOf(createHandyClient) |
| 27 | + .returns.toHaveProperty("zrevrange") |
| 28 | + .parameters.toEqualTypeOf<[string, number, number]>() |
| 29 | + |
| 30 | + expectTypeOf(createHandyClient) |
| 31 | + .returns.toHaveProperty("zrevrange") |
| 32 | + .returns.resolves.items.toBeString() |
| 33 | + |
| 34 | + expectTypeOf(createHandyClient) |
| 35 | + .returns.toHaveProperty("quit") |
| 36 | + .returns.resolves.toBeAny() |
| 37 | + |
| 38 | + expectTypeOf(createHandyClient) |
| 39 | + .returns.toHaveProperty("end") |
| 40 | + .returns.toEqualTypeOf<void>() |
| 41 | +}) |
0 commit comments