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.
47 lines (42 loc) • 1.53 kB
JavaScript
import { DateTimeType, TextType, IntegerType } from "../../src/values/index.js";
import { LabelParameter } from "../../src/parameters/index.js";
import { TzProperty } from "../../src/properties/index.js";
import { assert } from "chai";
describe("TzProperty tests", () => {
it("Accepts valid input", () => {
assert.doesNotThrow(
() => new TzProperty([], new TextType("Raleigh/North America"))
);
assert.doesNotThrow(
() => new TzProperty([], new DateTimeType("utcoffset", "-0500"))
);
});
it("Rejects invalid input", () => {
assert.throws(() => new TzProperty([], new IntegerType(55)));
assert.throws(
() =>
new TzProperty(
[new LabelParameter("Hello world")],
new TextType("Raleigh/North America")
)
);
assert.throws(() => new TzProperty());
assert.throws(() => new TzProperty(1));
assert.throws(() => new TzProperty({}));
assert.throws(() => new TzProperty("James Bond"));
});
it("Formats value properly", () => {
assert.strictEqual(
new TzProperty([], new TextType("Raleigh/North America")).repr(),
"TZ:Raleigh/North America"
);
assert.strictEqual(
new TzProperty([], new TextType("Raleigh/North America")).reprXML(),
"<tz><text>Raleigh/North America</text></tz>"
);
assert.deepEqual(
new TzProperty([], new TextType("Raleigh/North America")).reprJSON(),
["tz", {}, "text", "Raleigh/North America"]
);
});
});