2020-08-03 14:58:30 +12:00
|
|
|
import { expect } from "chai";
|
|
|
|
import { Formatter } from "export/formatter";
|
|
|
|
import { CustomProperties } from "./custom-properties";
|
|
|
|
|
|
|
|
describe("CustomProperties", () => {
|
|
|
|
describe("#constructor()", () => {
|
|
|
|
it("sets the appropriate attributes on the top-level", () => {
|
|
|
|
const properties = new CustomProperties([]);
|
|
|
|
const tree = new Formatter().format(properties);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
Properties: {
|
|
|
|
_attr: {
|
2020-08-04 08:50:56 +12:00
|
|
|
xmlns: "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
|
2020-08-03 14:58:30 +12:00
|
|
|
"xmlns:vt": "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
it("should create custom properties with all the attributes given", () => {
|
2020-08-04 08:50:56 +12:00
|
|
|
const properties = new CustomProperties([
|
|
|
|
{ name: "Address", value: "123" },
|
|
|
|
{ name: "Author", value: "456" },
|
|
|
|
]);
|
2020-08-03 14:58:30 +12:00
|
|
|
const tree = new Formatter().format(properties);
|
|
|
|
expect(tree).to.deep.equal({
|
|
|
|
Properties: [
|
|
|
|
{
|
|
|
|
_attr: {
|
2020-08-04 08:50:56 +12:00
|
|
|
xmlns: "http://schemas.openxmlformats.org/officeDocument/2006/custom-properties",
|
2020-08-03 14:58:30 +12:00
|
|
|
"xmlns:vt": "http://schemas.openxmlformats.org/officeDocument/2006/docPropsVTypes",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: [
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
|
|
|
|
pid: "2",
|
|
|
|
name: "Address",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-08-04 08:50:56 +12:00
|
|
|
"vt:lpwstr": ["123"],
|
2020-08-03 14:58:30 +12:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
{
|
|
|
|
property: [
|
|
|
|
{
|
|
|
|
_attr: {
|
|
|
|
fmtid: "{D5CDD505-2E9C-101B-9397-08002B2CF9AE}",
|
|
|
|
pid: "3",
|
|
|
|
name: "Author",
|
|
|
|
},
|
|
|
|
},
|
|
|
|
{
|
2020-08-04 08:50:56 +12:00
|
|
|
"vt:lpwstr": ["456"],
|
2020-08-03 14:58:30 +12:00
|
|
|
},
|
|
|
|
],
|
|
|
|
},
|
|
|
|
],
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|
|
|
|
});
|