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.
63 lines (59 loc) • 1.75 kB
JavaScript
import { TextType, IntegerType } from "../../src/values/index.js";
import { NoteProperty } from "../../src/properties/index.js";
import { assert } from "chai";
describe("NoteProperty tests", () => {
it("Accepts valid input", () => {
assert.doesNotThrow(
() =>
new NoteProperty(
[],
new TextType(
"This fax number is operational 0800 to 1715 EST, Mon-Fri."
)
)
);
});
it("Rejects invalid input", () => {
assert.throws(
() => new NoteProperty([new IntegerType(55)], new IntegerType(55))
);
assert.throws(() => new NoteProperty());
assert.throws(() => new NoteProperty(1));
assert.throws(() => new NoteProperty({}));
assert.throws(() => new NoteProperty("James Bond"));
});
it("Formats value properly", () => {
assert.strictEqual(
new NoteProperty(
[],
new TextType(
"This fax number is operational 0800 to 1715 EST, Mon-Fri."
)
).repr(),
"NOTE:This fax number is operational 0800 to 1715 EST\\, Mon-Fri."
);
assert.strictEqual(
new NoteProperty(
[],
new TextType(
"This fax number is operational 0800 to 1715 EST, Mon-Fri."
)
).reprXML(),
"<note><text>This fax number is operational 0800 to 1715 EST, Mon-Fri.</text></note>"
);
assert.deepEqual(
new NoteProperty(
[],
new TextType(
"This fax number is operational 0800 to 1715 EST, Mon-Fri."
)
).reprJSON(),
[
"note",
{},
"text",
"This fax number is operational 0800 to 1715 EST, Mon-Fri.",
]
);
});
});