vcard4
Version:
An RFC 6350 compliant JavaScript library for generating and parsing version 4.0 vCards. Can also generate RFC 6351 compliant XML vCards and RFC 7095 compliant jCards. TypeScript type declarations are provided.
37 lines (33 loc) • 1.19 kB
JavaScript
import { TextType, IntegerType } from "../../src/values/index.js";
import { RoleProperty } from "../../src/properties/index.js";
import { assert } from "chai";
describe("RoleProperty tests", () => {
it("Accepts valid input", () => {
assert.doesNotThrow(
() => new RoleProperty([], new TextType("Project Leader"))
);
});
it("Rejects invalid input", () => {
assert.throws(
() => new RoleProperty([new IntegerType(55)], new IntegerType(55))
);
assert.throws(() => new RoleProperty());
assert.throws(() => new RoleProperty(1));
assert.throws(() => new RoleProperty({}));
assert.throws(() => new RoleProperty("James Bond"));
});
it("Formats value properly", () => {
assert.strictEqual(
new RoleProperty([], new TextType("Project Leader")).repr(),
"ROLE:Project Leader"
);
assert.strictEqual(
new RoleProperty([], new TextType("Project Leader")).reprXML(),
"<role><text>Project Leader</text></role>"
);
assert.deepEqual(
new RoleProperty([], new TextType("Project Leader")).reprJSON(),
["role", {}, "text", "Project Leader"]
);
});
});