Files
docx-js/src/file/document/document.spec.ts

54 lines
2.5 KiB
TypeScript
Raw Normal View History

2019-07-31 08:48:02 +01:00
import { expect } from "chai";
2018-10-26 01:04:07 +01:00
import { Formatter } from "export/formatter";
2018-01-31 01:23:13 +00:00
import { Document } from "./document";
2016-03-29 04:10:33 +01:00
2016-04-03 05:24:56 +01:00
describe("Document", () => {
2018-01-31 01:23:13 +00:00
let document: Document;
2016-03-29 04:10:33 +01:00
beforeEach(() => {
2020-10-27 01:54:40 +00:00
document = new Document({ background: {} });
2016-03-29 04:10:33 +01:00
});
2016-05-26 15:08:34 +01:00
describe("#constructor()", () => {
2016-03-29 04:10:33 +01:00
it("should create valid JSON", () => {
2019-07-31 08:48:02 +01:00
const tree = new Formatter().format(document);
2016-03-29 04:10:33 +01:00
2019-07-31 08:48:02 +01:00
expect(tree).to.deep.equal({
"w:document": [
{
_attr: {
"xmlns:wpc": "http://schemas.microsoft.com/office/word/2010/wordprocessingCanvas",
"xmlns:mc": "http://schemas.openxmlformats.org/markup-compatibility/2006",
"xmlns:o": "urn:schemas-microsoft-com:office:office",
"xmlns:r": "http://schemas.openxmlformats.org/officeDocument/2006/relationships",
"xmlns:m": "http://schemas.openxmlformats.org/officeDocument/2006/math",
"xmlns:v": "urn:schemas-microsoft-com:vml",
"xmlns:wp14": "http://schemas.microsoft.com/office/word/2010/wordprocessingDrawing",
"xmlns:wp": "http://schemas.openxmlformats.org/drawingml/2006/wordprocessingDrawing",
"xmlns:w10": "urn:schemas-microsoft-com:office:word",
"xmlns:w": "http://schemas.openxmlformats.org/wordprocessingml/2006/main",
"xmlns:w14": "http://schemas.microsoft.com/office/word/2010/wordml",
"xmlns:w15": "http://schemas.microsoft.com/office/word/2012/wordml",
"xmlns:wpg": "http://schemas.microsoft.com/office/word/2010/wordprocessingGroup",
"xmlns:wpi": "http://schemas.microsoft.com/office/word/2010/wordprocessingInk",
"xmlns:wne": "http://schemas.microsoft.com/office/word/2006/wordml",
"xmlns:wps": "http://schemas.microsoft.com/office/word/2010/wordprocessingShape",
"mc:Ignorable": "w14 w15 wp14",
},
},
2020-10-27 01:54:40 +00:00
{
"w:background": {
_attr: {
2020-10-28 01:05:31 +00:00
"w:color": "FFFFFF",
2020-10-27 01:54:40 +00:00
},
},
},
2019-07-31 08:48:02 +01:00
{ "w:body": {} },
],
});
});
2016-03-29 04:10:33 +01:00
});
2017-03-09 22:31:55 +00:00
});