-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathhincrbyfloat.test.ts
37 lines (30 loc) · 1.4 KB
/
hincrbyfloat.test.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
import { createNodeRedisClient } from "../../../src";
import { fuzzify } from "../../fuzzify";
const client = createNodeRedisClient();
beforeAll(async () => {
await client.ping();
});
beforeEach(async () => {
await client.flushall();
});
test("docs/redis-doc/commands/hincrbyfloat.md example 1", async () => {
const outputs: Record<string, unknown> = {};
outputs.r0 = await client.hset("mykey", ["field", "10.50"]);
outputs.r1 = await client.hincrbyfloat("mykey", "field", 0.1);
outputs.r2 = await client.hincrbyfloat("mykey", "field", -5);
outputs.r3 = await client.hset("mykey", ["field", "5.0e3"]);
// Error decoding command `HINCRBYFLOAT mykey field 2.0e2`:
// decoding HINCRBYFLOAT overload 0 (key,field,increment): {name:'key',schema:{title:'key',type:'string'}},{name:'field',schema:{title:'field',type:'string'}},{name:'increment',schema:{title:'increment',type:'number'}}
// mykey successfully decoded as key (string). Decoded value mykey. Tokens remaining [field,2.0e2], target args remainin count: 2
// field successfully decoded as field (string). Decoded value field. Tokens remaining [2.0e2], target args remainin count: 1
// 2.0e2 parsed into a bad number 200
// ---
expect(fuzzify(outputs, __filename)).toMatchInlineSnapshot(`
Object {
"r0": 1,
"r1": "10.6",
"r2": "5.6",
"r3": 0,
}
`);
});