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.

66 lines (62 loc) 2.02 kB
import { TextType, SpecialValueType } from "../../src/values/index.js"; import { OrgProperty } from "../../src/properties/index.js"; import { assert } from "chai"; describe("OrgProperty tests", () => { it("Accepts valid input", () => { assert.doesNotThrow( () => new OrgProperty( [], new SpecialValueType("orgproperty", [ new TextType("ABC, Inc."), new TextType("North American Division"), new TextType("Marketing"), ]) ) ); }); it("Rejects invalid input", () => { assert.throws( () => new OrgProperty([new IntegerType(55)], new IntegerType(55)) ); assert.throws(() => new OrgProperty()); assert.throws(() => new OrgProperty(1)); assert.throws(() => new OrgProperty({})); assert.throws(() => new OrgProperty("James Bond")); }); it("Formats value properly", () => { assert.strictEqual( new OrgProperty( [], new SpecialValueType("orgproperty", [ new TextType("ABC, Inc."), new TextType("North American Division"), new TextType("Marketing"), ]) ).repr(), "ORG:ABC\\, Inc.;North American Division;Marketing" ); assert.strictEqual( new OrgProperty( [], new SpecialValueType("orgproperty", [ new TextType("ABC, Inc."), new TextType("North American Division"), new TextType("Marketing"), ]) ).reprXML(), "<org><text>ABC, Inc.</text><text>North American Division</text><text>Marketing</text></org>" ); assert.deepEqual( new OrgProperty( [], new SpecialValueType("orgproperty", [ new TextType("ABC, Inc."), new TextType("North American Division"), new TextType("Marketing"), ]) ).reprJSON(), ["org", {}, "text", ["ABC, Inc.", "North American Division", "Marketing"]] ); }); });