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.5 kB
JavaScript
import { URIType, IntegerType } from "../../src/values/index.js";
import { UIDProperty } from "../../src/properties/index.js";
import { assert } from "chai";
describe("UIDProperty tests", () => {
it("Accepts valid input", () => {
assert.doesNotThrow(
() =>
new UIDProperty(
[],
new URIType("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6")
)
);
});
it("Rejects invalid input", () => {
assert.throws(
() => new UIDProperty([new IntegerType(55)], new IntegerType(55))
);
assert.throws(() => new UIDProperty());
assert.throws(() => new UIDProperty(1));
assert.throws(() => new UIDProperty({}));
assert.throws(() => new UIDProperty("James Bond"));
});
it("Formats value properly", () => {
assert.strictEqual(
new UIDProperty(
[],
new URIType("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6")
).repr(),
"UID:urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6"
);
assert.strictEqual(
new UIDProperty(
[],
new URIType("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6")
).reprXML(),
"<uid><uri>urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6</uri></uid>"
);
assert.deepEqual(
new UIDProperty(
[],
new URIType("urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6")
).reprJSON(),
["uid", {}, "uri", "urn:uuid:f81d4fae-7dec-11d0-a765-00a0c91e6bf6"]
);
});
});