import { assert } from "chai"; import { describe, it, beforeEach, afterEach } from "node:test"; import * as m from "../index"; import * as config from "./config"; import { LocationKindType } from "../constants"; describe("ADSB", 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 models.ADSB.deleteMany({}); await mongoose.disconnect(); }); it("is saved", async function() { const item = new models.ADSB({ tailNumber: "N123TC", locationType: LocationKindType.FixedWing, }); const sut = await item.save(); assert.equal(sut.tailNumber, "N123TC"); assert.equal(sut.locationType, LocationKindType.FixedWing); assert.equal(sut.radioName, ""); assert.equal(sut.notes, ""); assert.instanceOf(sut.modifiedDate, Date); }); it("defaults kind and type to empty strings", async function() { const sut = await new models.ADSB({ tailNumber: "N321TC", locationType: LocationKindType.Helicopter, }).save(); assert.equal(sut.kind, ""); assert.equal(sut.type, ""); }); it("persists kind and type", async function() { const sut = await new models.ADSB({ tailNumber: "N777TC", locationType: LocationKindType.Helicopter, kind: "helicopter", type: "1", }).save(); assert.equal(sut.kind, "helicopter"); assert.equal(sut.type, "1"); }); });