import { assert } from "chai"; import { describe, it, beforeEach, afterEach } from "node:test"; import * as m from "../index"; import { url } from "./config"; import mockModule from "./mock"; describe("IncidentFilter", function() { let models: m.BackendModels, mongoose: m.MongooseModule; let testItem: Partial; beforeEach(async function() { const c = await m.connect(url); models = c.models; mongoose = c.mongoose; const mock = mockModule({ mongoose }); testItem = mock.incidentFilterAgency; await mock.beforeEach(); }); afterEach(async function() { await mongoose.disconnect(); }); it("is saved", async function() { assert.isObject(testItem); const item = new models.IncidentFilter(testItem); const sut = await item.save(); assert.equal(sut.name, testItem.name); assert.equal(sut.position, testItem.position); assert.equal(sut.kind, m.IncidentFilterKind.AgencyId); assert.equal(sut.departmentId, testItem.departmentId); const if1o1 = sut.options.find(() => true); assert.equal(if1o1?.name, "Opt 1"); assert.equal(if1o1?.position, 10); assert.equal(if1o1?.value, "P1"); }); });