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.

47 lines (43 loc) 1.56 kB
import { DateTimeType, TextType } from "../../src/values/index.js"; import { ValueParameter } from "../../src/parameters/index.js"; import { DeathPlaceProperty } from "../../src/properties/index.js"; import { assert } from "chai"; describe("DeathPlaceProperty tests", () => { it("Accepts valid input", () => { assert.doesNotThrow( () => new DeathPlaceProperty([], new TextType("The hospital")) ); }); it("Rejects invalid input", () => { assert.throws( () => new DeathPlaceProperty([], new DateTimeType("19960415", "date")) ); assert.throws(() => new DeathPlaceProperty()); assert.throws(() => new DeathPlaceProperty(1)); assert.throws(() => new DeathPlaceProperty({})); assert.throws(() => new DeathPlaceProperty("James Bond")); }); it("Formats value properly", () => { assert.strictEqual( new DeathPlaceProperty( [new ValueParameter(new TextType("The hospital"))], new TextType("The hospital") ).repr(), "DEATHPLACE;VALUE=text:The hospital" ); assert.strictEqual( new DeathPlaceProperty( [new ValueParameter(new TextType("The hospital"))], new TextType("The hospital") ).reprXML(), "<deathplace><text>The hospital</text></deathplace>" ); assert.deepEqual( new DeathPlaceProperty( [new ValueParameter(new TextType("The hospital"))], new TextType("The hospital") ).reprJSON(), ["deathplace", {}, "text", "The hospital"] ); }); });