forked from Yara724/api
39 lines
1.4 KiB
TypeScript
39 lines
1.4 KiB
TypeScript
import { SEED_FANAVARAN_CLIENT_PROFILES } from "src/core/config/fanavaran-client.config";
|
|
import { FanavaranClientConfigService } from "./fanavaran-client-config.service";
|
|
|
|
describe("Moallem attachment file type", () => {
|
|
it("seeds file type 17 for Moallem and retains the other tenant file types", () => {
|
|
expect(
|
|
SEED_FANAVARAN_CLIENT_PROFILES.moallem.defaults.ClaimFileTypeId,
|
|
).toBe(17);
|
|
expect(
|
|
SEED_FANAVARAN_CLIENT_PROFILES.parsian.defaults.ClaimFileTypeId,
|
|
).toBe(63);
|
|
expect(
|
|
SEED_FANAVARAN_CLIENT_PROFILES.tejaratno.defaults.ClaimFileTypeId,
|
|
).toBe(23);
|
|
});
|
|
|
|
it("migrates only Moallem's old shared default on existing installations", async () => {
|
|
const service = Object.create(
|
|
FanavaranClientConfigService.prototype,
|
|
) as any;
|
|
service.configModel = {
|
|
updateOne: jest.fn().mockResolvedValue({ modifiedCount: 1 }),
|
|
findOne: jest.fn().mockReturnValue({
|
|
select: () => ({
|
|
lean: () => ({ exec: async () => ({ _id: "existing" }) }),
|
|
}),
|
|
}),
|
|
create: jest.fn(),
|
|
};
|
|
await service.seedMissingProfiles();
|
|
expect(service.configModel.updateOne).toHaveBeenCalledTimes(1);
|
|
expect(service.configModel.updateOne).toHaveBeenCalledWith(
|
|
{ key: "moallem", "defaults.ClaimFileTypeId": 23 },
|
|
{ $set: { "defaults.ClaimFileTypeId": 17 } },
|
|
);
|
|
expect(service.configModel.create).not.toHaveBeenCalled();
|
|
});
|
|
});
|