UNPKG

realm-object-server

Version:

Realm Object Server

51 lines 2.53 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); const chai_1 = require("chai"); const portfinder = require("portfinder"); const path = require("path"); const SyncService_1 = require("./SyncService"); const TestServer_1 = require("../TestServer"); describe("SyncService", () => { let syncService; let server; beforeEach(() => __awaiter(this, void 0, void 0, function* () { server = new TestServer_1.TestServer(); yield server.start(); })); afterEach(() => __awaiter(this, void 0, void 0, function* () { yield server.shutdown().catch((err) => { }); })); describe("with minimal configuration", () => { it("should use default address and an ephemeral port", () => __awaiter(this, void 0, void 0, function* () { syncService = new SyncService_1.SyncService({ dataPath: path.join(server.dataPath, "sync2"), }); yield syncService["start"](server); chai_1.assert.equal(syncService["address"]().address, "127.0.0.1"); chai_1.assert.isAtLeast(syncService["address"]().port, 32768); chai_1.assert.isAtMost(syncService["address"]().port, 65535); })); }); describe("with configured address and port", () => { it("should use supplied address and port", () => __awaiter(this, void 0, void 0, function* () { const port = yield portfinder.getPortPromise(); syncService = new SyncService_1.SyncService({ listenAddress: "0.0.0.0", listenPort: port, dataPath: path.join(server.dataPath, "sync2"), }); yield syncService["start"](server); chai_1.assert.equal(syncService["address"]().address, "0.0.0.0"); chai_1.assert.equal(syncService["address"]().port, port); })); }); }); //# sourceMappingURL=SyncService.spec.js.map