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.
62 lines (58 loc) • 1.9 kB
JavaScript
import { URIType, LanguageTagType, TextType } from "../../src/values/index.js";
import { LanguageParameter } from "../../src/parameters/index.js";
import { PhotoProperty } from "../../src/properties/index.js";
import { assert } from "chai";
describe("PhotoProperty tests", () => {
it("Accepts valid input", () => {
assert.doesNotThrow(
() =>
new PhotoProperty(
[],
new URIType("http://www.example.com/pub/photos/jqpublic.gif")
)
);
});
it("Rejects invalid input", () => {
assert.throws(
() =>
new PhotoProperty(
[],
new TextType("http://www.example.com/pub/photos/jqpublic.gif")
)
);
assert.throws(
() =>
new PhotoProperty(
[new LanguageParameter(new LanguageTagType("en"))],
new URIType("http://www.example.com/pub/photos/jqpublic.gif")
)
);
assert.throws(() => new PhotoProperty());
assert.throws(() => new PhotoProperty(1));
assert.throws(() => new PhotoProperty({}));
assert.throws(() => new PhotoProperty("James Bond"));
});
it("Formats value properly", () => {
assert.strictEqual(
new PhotoProperty(
[],
new URIType("http://www.example.com/pub/photos/jqpublic.gif")
).repr(),
"PHOTO:http://www.example.com/pub/photos/jqpublic.gif"
);
assert.strictEqual(
new PhotoProperty(
[],
new URIType("http://www.example.com/pub/photos/jqpublic.gif")
).reprXML(),
"<photo><uri>http://www.example.com/pub/photos/jqpublic.gif</uri></photo>"
);
assert.deepEqual(
new PhotoProperty(
[],
new URIType("http://www.example.com/pub/photos/jqpublic.gif")
).reprJSON(),
["photo", {}, "uri", "http://www.example.com/pub/photos/jqpublic.gif"]
);
});
});