import { assert } from "chai"; import { describe, it, beforeEach, afterEach } from "node:test"; import * as m from "../index"; import * as config from "./config"; describe("ChartIncident", function() { let models: m.BackendModels, mongoose: m.MongooseModule; beforeEach(async function() { const c = await m.connect(config.url); models = c.models; mongoose = c.mongoose; }); afterEach(async function() { await mongoose.disconnect(); }); it("is saved", async function() { const departmentId = new mongoose.Types.ObjectId().toString(); const testItem: Partial = { departmentId, dateAt: new Date("2024-06-15T00:00:00.000Z"), count: 5, items: [ { item: "item1", dateAt: new Date("2024-06-15T01:00:00.000Z") }, ], }; const item = new models.ChartIncident(testItem); const sut = await item.save(); assert.isNotNull(sut._id); assert.equal(sut.departmentId, departmentId); assert.equal(sut.count, 5); assert.equal(sut.items.length, 1); assert.equal(sut.items[0]!.item, "item1"); }); });