Path: blob/master/src/packages/backend/conat/test/persist/persist-dstream.test.ts
1451 views
/*1Testing things about dstream that involve persistence.2*/34import {5before,6after,7connect,8delay,9} from "@cocalc/backend/conat/test/setup";1011beforeAll(before);1213describe("create a dstream, write data, close it, then open it again and see data persisted", () => {14let client;15const name = "foo";16it("create clients and a document", async () => {17client = connect();18const v = await client.sync.dstream({ name });19v.publish("x");20await v.save();21v.close();22});2324it("opening again and see that it persisted", async () => {25const v = await client.sync.dstream({ name });26expect(v.getAll()).toEqual(["x"]);27});28});2930// this is here because I had a bug in the syncRefCache that this exposed.31describe("just like above, create a dstream, write data, close it, then open it again and see data persisted -- **but do it all in the same function**", () => {32let client;33const name = "foo2";34it("create clients and a document", async () => {35client = connect();36const v = await client.sync.dstream({ name });37v.publish("x");38await v.save();39v.close();40const w = await client.sync.dstream({ name });41expect(w.getAll()).toEqual(["x"]);42w.close();43});44});4546afterAll(async () => {47await delay(100);48after();49});505152