summaryrefslogtreecommitdiff
path: root/server/src/server.test.ts
blob: 2bd2e45eb8175a579eace65a84ac0243aab05de1 (plain)
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
import { runServer } from "./server";
import process from "process";

// We test the server using the client.
// It would be better to import this
// from a linked npm package,
// but that requires rebuilding each time
// so fuck it for now
import { dbFactory, DatabaseConnection } from "../../client/src";

const port = +(process.env.PORT || 5005);
const httpPort = port;
const wsPort = port + 1;

describe("Server module", async () => {
  let db: DatabaseConnection;
  beforeAll(async () => {
    await runServer({
      httpPort,
      wsPort,
      logger: console.log
    });
    db = dbFactory({ wsPort, httpUrl: `http://localhost:${httpPort}` });
    await db.init();
  });
  test("it should work", async () => {
    await db.write("/hello/world", {
      my: "data"
    });
  });
});