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.
50 lines (46 loc) • 1.44 kB
JavaScript
import {
SpecialValueType,
IntegerType,
URIType,
} from "../../src/values/index.js";
import { assert } from "chai";
describe("SpecialValueType tests", () => {
it("Accepts valid input", () => {
assert.doesNotThrow(() => new SpecialValueType("kindproperty", "group"));
assert.doesNotThrow(
() =>
new SpecialValueType("clientpidmapProperty", [
new IntegerType(1),
new URIType("uuid:123-asmm-aams"),
])
);
});
it("Rejects invalid input", () => {
assert.throws(() => new SpecialValueType());
assert.throws(() => new SpecialValueType("FNProperty", "something"));
assert.throws(() => new SpecialValueType({}));
});
it("Formats value properly", () => {
assert.strictEqual(
new SpecialValueType("clientpidmapProperty", [
new IntegerType(1),
new URIType("uuid:123-asmm-aams"),
]).repr(),
"1;uuid:123-asmm-aams"
);
assert.strictEqual(
new SpecialValueType("clientpidmapProperty", [
new IntegerType(1),
new URIType("uuid:123-asmm-aams"),
]).reprXML(),
"<integer>1</integer><uri>uuid:123-asmm-aams</uri>"
);
assert.deepEqual(
new SpecialValueType("clientpidmapProperty", [
new IntegerType(1),
new URIType("uuid:123-asmm-aams"),
]).reprJSON(),
["unknown", [1, "uuid:123-asmm-aams"]]
);
});
});