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.

43 lines (39 loc) 1.24 kB
import { TextType, TextListType, IntegerType } from "../../src/values/index.js"; import { assert } from "chai"; describe("TextListType tests", () => { it("Accepts valid input", () => { assert.doesNotThrow(() => { new TextListType([ new TextType("Greeting: Hello, world!"), new TextType("Greeting: Hello, world!"), new TextType("Greeting: Hello, world!"), ]); }); }); it("Rejects invalid input", () => { assert.throws(() => new TextListType(1)); assert.throws(() => new TextListType()); assert.throws(() => new TextListType([new IntegerType(100)])); assert.throws(() => new TextListType({})); }); it("Formats value properly", () => { assert.strictEqual( new TextListType([new TextType("Hello"), new TextType("world")]).repr(), "Hello,world" ); assert.strictEqual( new TextListType([ new TextType("Hello"), new TextType("world"), ]).reprXML(), "<text>Hello</text><text>world</text>" ); assert.deepEqual( new TextListType([ new TextType("Hello"), new TextType("world"), ]).reprJSON(), ["text", "Hello", "world"] ); }); });