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.69 kB
import { ParameterValueType } from "../../src/values/index.js"; import { LabelParameter } from "../../src/parameters/index.js"; import { assert } from "chai"; describe("LabelParameter tests", () => { it("Accepts valid input", () => { assert.doesNotThrow( () => new LabelParameter(new ParameterValueType("Somestreet, somewhere")) ); }); it("Rejects invalid input", () => { assert.throws(() => new LabelParameter()); assert.throws(() => new LabelParameter(1)); assert.throws(() => new LabelParameter({})); }); it("Formats value properly", () => { assert.strictEqual( new LabelParameter( new ParameterValueType( `Mr. John Q. Public, Esq. Mail Drop: TNE QB 123 Main Street Any Town, CA 91921-1234 U.S.A.` ) ).repr(), 'LABEL="Mr. John Q. Public, Esq.^nMail Drop: TNE QB^n123 Main Street^nAny Town, CA 91921-1234^nU.S.A."' ); assert.strictEqual( new LabelParameter( new ParameterValueType( `Mr. John Q. Public, Esq. Mail Drop: TNE QB 123 Main Street Any Town, CA 91921-1234 U.S.A.` ) ).reprXML(), "<label><text>Mr. John Q. Public, Esq.\nMail Drop: TNE QB\n123 Main Street\nAny Town, CA 91921-1234\nU.S.A.</text></label>" ); assert.deepEqual( new LabelParameter( new ParameterValueType( `Mr. John Q. Public, Esq. Mail Drop: TNE QB 123 Main Street Any Town, CA 91921-1234 U.S.A.` ) ).reprJSON(), { label: "Mr. John Q. Public, Esq.\nMail Drop: TNE QB\n123 Main Street\nAny Town, CA 91921-1234\nU.S.A.", } ); }); });