Published
Edited
Jul 28, 2022
Importers
7 stars
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
Insert cell
p = tests.test(`sendCommand(["PING"]) returns 'PONG'`, async () => {
const result = await client.sendCommand(["PING"]);
expect(result).toBe("PONG");
})
Insert cell
setKey = tests.test(
'sendCommand(["SET", "key", "value"]) returns "OK"',
async () => {
const result = await client.sendCommand(["SET", "key", "value"]);
expect(result).toBe("OK");
}
)
Insert cell
b3 = tests.test('sendCommand(["GET", "key"]) returns foobar', async () => {
setKey; // ensure setKey run first
const result = await client.sendCommand(["GET", "key"]);
expect(result).toBe("value");
})
Insert cell
Insert cell
Insert cell
tests.test(
'subscribe("foo", listener) receives (message, foo)',
async (done) => {
await subClient.subscribe("foo", (message, channel) => {
expect(message).toBe("bar");
expect(channel).toBe("foo");
done();
});
client.sendCommand(["PUBLISH", "foo", "bar"]);
}
)
Insert cell
Insert cell
Insert cell
tests.test("BLPOP blocks until RPUSH", async () => {
const result = blockClient.sendCommand(["BLPOP", "list0", "0"]);
client.sendCommand(["LPUSH", "list0", "v1"]);
expect(await result).toEqual(["list0", "v1"]);
})
Insert cell
Insert cell
Insert cell
multi1 = tests.test("MULTI/EXEC block", async () => {
transClient.sendCommand(["MULTI"]);
transClient.sendCommand(["SET", "k0", "v0"]);
transClient.sendCommand(["SET", "k1", "v0"]);
const result = await transClient.sendCommand(["EXEC"]);
expect(result).toEqual(["OK", "OK"]);
})
Insert cell
Insert cell
Insert cell
tests.test("WATCH atomic increment", async () => {
multi1;
transClient.sendCommand(["WATCH", "k1"]);
const v = transClient.sendCommand(["GET", "k1"]);
transClient.sendCommand(["MULTI"]);
transClient.sendCommand(["SET", "k1", Number.parseInt(await v) + 1 + ""]);
const result = await transClient.sendCommand(["EXEC"]);
expect(result).toEqual(["OK"]);
})
Insert cell
Insert cell
Insert cell
Insert cell

Purpose-built for displays of data

Observable is your go-to platform for exploring data and creating expressive data visualizations. Use reactive JavaScript notebooks for prototyping and a collaborative canvas for visual data exploration and dashboard creation.
Learn more