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.

57 lines (53 loc) 1.69 kB
import { URIType, IntegerType } from "../../src/values/index.js"; import { SoundProperty } from "../../src/properties/index.js"; import { assert } from "chai"; describe("SoundProperty tests", () => { it("Accepts valid input", () => { assert.doesNotThrow( () => new SoundProperty( [], new URIType( "CID:JOHNQPUBLIC.part8.19960229T080000.xyzMail@example.com" ) ) ); }); it("Rejects invalid input", () => { assert.throws( () => new SoundProperty([new IntegerType(55)], new IntegerType(55)) ); assert.throws(() => new SoundProperty()); assert.throws(() => new SoundProperty(1)); assert.throws(() => new SoundProperty({})); assert.throws(() => new SoundProperty("James Bond")); }); it("Formats value properly", () => { assert.strictEqual( new SoundProperty( [], new URIType("CID:JOHNQPUBLIC.part8.19960229T080000.xyzMail@example.com") ).repr(), "SOUND:CID:JOHNQPUBLIC.part8.19960229T080000.xyzMail@example.com" ); assert.strictEqual( new SoundProperty( [], new URIType("CID:JOHNQPUBLIC.part8.19960229T080000.xyzMail@example.com") ).reprXML(), "<sound><uri>CID:JOHNQPUBLIC.part8.19960229T080000.xyzMail@example.com</uri></sound>" ); assert.deepEqual( new SoundProperty( [], new URIType("CID:JOHNQPUBLIC.part8.19960229T080000.xyzMail@example.com") ).reprJSON(), [ "sound", {}, "uri", "CID:JOHNQPUBLIC.part8.19960229T080000.xyzMail@example.com", ] ); }); });