UNPKG

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.

60 lines (56 loc) 1.97 kB
import { URIType, IntegerType, ParameterValueType, } from "../../src/values/index.js"; import { MediatypeParameter } from "../../src/parameters/index.js"; import { CaluriProperty } from "../../src/properties/index.js"; import { assert } from "chai"; describe("CaluriProperty tests", () => { it("Accepts valid input", () => { assert.doesNotThrow( () => new CaluriProperty( [new MediatypeParameter(new ParameterValueType("text/calendar"))], new URIType("ftp://ftp.example.com/calA.ics") ) ); }); it("Rejects invalid input", () => { assert.throws( () => new CaluriProperty([new IntegerType(55)], new IntegerType(55)) ); assert.throws(() => new CaluriProperty()); assert.throws(() => new CaluriProperty(1)); assert.throws(() => new CaluriProperty({})); assert.throws(() => new CaluriProperty("James Bond")); }); it("Formats value properly", () => { assert.strictEqual( new CaluriProperty( [new MediatypeParameter(new ParameterValueType("text/calendar"))], new URIType("ftp://ftp.example.com/calA.ics") ).repr(), "CALURI;MEDIATYPE=text/calendar:ftp://ftp.example.com/calA.ics" ); assert.strictEqual( new CaluriProperty( [new MediatypeParameter(new ParameterValueType("text/calendar"))], new URIType("ftp://ftp.example.com/calA.ics") ).reprXML(), "<caluri><parameters><mediatype><text>text/calendar</text></mediatype></parameters><uri>ftp://ftp.example.com/calA.ics</uri></caluri>" ); assert.deepEqual( new CaluriProperty( [new MediatypeParameter(new ParameterValueType("text/calendar"))], new URIType("ftp://ftp.example.com/calA.ics") ).reprJSON(), [ "caluri", { mediatype: "text/calendar" }, "uri", "ftp://ftp.example.com/calA.ics", ] ); }); });