39 lines
1.3 KiB
TypeScript
39 lines
1.3 KiB
TypeScript
import assert from "node:assert/strict";
|
|
import test from "node:test";
|
|
import { parseZammadOrganizationAttributeOptions } from "../src/zammadOrganizationAttributes.ts";
|
|
|
|
test("parses the two organization select attributes and ignores unrelated attributes", () => {
|
|
const options = parseZammadOrganizationAttributeOptions([
|
|
{
|
|
id: 85,
|
|
name: "customer_owner",
|
|
data_option: { options: { ATOSS: "ATOSS", sdw: "SD Worx" } }
|
|
},
|
|
{
|
|
id: 12,
|
|
name: "unrelated",
|
|
data_option: { options: { no: "No" } }
|
|
},
|
|
{
|
|
id: 86,
|
|
name: "hotline_contract",
|
|
data_option: { options: { none: "(kein Hotlinevertrag)" } }
|
|
}
|
|
]);
|
|
|
|
assert.deepEqual(options, [
|
|
{ zammadAttributeId: 85, attributeName: "customer_owner", optionKey: "ATOSS", displayName: "ATOSS" },
|
|
{ zammadAttributeId: 85, attributeName: "customer_owner", optionKey: "sdw", displayName: "SD Worx" },
|
|
{ zammadAttributeId: 86, attributeName: "hotline_contract", optionKey: "none", displayName: "(kein Hotlinevertrag)" }
|
|
]);
|
|
});
|
|
|
|
test("rejects responses without both required attributes", () => {
|
|
assert.throws(
|
|
() => parseZammadOrganizationAttributeOptions([
|
|
{ id: 85, name: "customer_owner", data_option: { options: { ATOSS: "ATOSS" } } }
|
|
]),
|
|
/hotline_contract/
|
|
);
|
|
});
|