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.43 kB
JavaScript
import { TextType, DateTimeType } from "../../src/values/index.js";
import { LevelParameter } from "../../src/parameters/index.js";
import { ExpertiseProperty } from "../../src/properties/index.js";
import { assert } from "chai";
describe("ExpertiseProperty tests", () => {
it("Accepts valid input", () => {
assert.doesNotThrow(() => new ExpertiseProperty([], new TextType("golf")));
});
it("Rejects invalid input", () => {
assert.throws(
() =>
new ExpertiseProperty(
[new LevelParameter(new TextType("high"), "hobbyProperty")],
new TextType("golf")
)
);
assert.throws(
() => new ExpertiseProperty([], new DateTimeType("19960415", "date"))
);
assert.throws(() => new ExpertiseProperty());
assert.throws(() => new ExpertiseProperty(1));
assert.throws(() => new ExpertiseProperty({}));
assert.throws(() => new ExpertiseProperty("James Bond"));
});
it("Formats value properly", () => {
assert.strictEqual(
new ExpertiseProperty([], new TextType("golf")).repr(),
"EXPERTISE:golf"
);
assert.strictEqual(
new ExpertiseProperty([], new TextType("golf")).reprXML(),
"<expertise><text>golf</text></expertise>"
);
assert.deepEqual(
new ExpertiseProperty([], new TextType("golf")).reprJSON(),
["expertise", {}, "text", "golf"]
);
});
});