Fix tests

This commit is contained in:
Dolan Miu
2023-06-07 03:19:54 +01:00
parent e69b063687
commit 972fa77265
2 changed files with 7 additions and 8 deletions

View File

@ -61,7 +61,7 @@ describe("External styles factory", () => {
it("should parse other child elements of w:styles", () => { it("should parse other child elements of w:styles", () => {
// eslint-disable-next-line @typescript-eslint/no-explicit-any // eslint-disable-next-line @typescript-eslint/no-explicit-any
const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any; const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any;
expect(importedStyle.root[1]).to.deep.equal({ expect(JSON.parse(JSON.stringify(importedStyle.root[1]))).to.deep.equal({
root: [ root: [
{ {
root: [ root: [
@ -126,7 +126,7 @@ describe("External styles factory", () => {
], ],
rootKey: "w:docDefaults", rootKey: "w:docDefaults",
}); });
expect(importedStyle.root[2]).to.deep.equal({ expect(JSON.parse(JSON.stringify(importedStyle.root[2]))).to.deep.equal({
root: [ root: [
{ {
root: { root: {
@ -151,7 +151,7 @@ describe("External styles factory", () => {
const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any; const importedStyle = new ExternalStylesFactory().newInstance(externalStyles) as any;
expect(importedStyle.root.length).to.equal(5); expect(importedStyle.root.length).to.equal(5);
expect(importedStyle.root[3]).to.deep.equal({ expect(JSON.parse(JSON.stringify(importedStyle.root[3]))).to.deep.equal({
root: [ root: [
{ {
root: { root: {
@ -180,7 +180,7 @@ describe("External styles factory", () => {
rootKey: "w:style", rootKey: "w:style",
}); });
expect(importedStyle.root[4]).to.deep.equal({ expect(JSON.parse(JSON.stringify(importedStyle.root[4]))).to.deep.equal({
root: [ root: [
{ {
root: { root: {

View File

@ -44,7 +44,6 @@ const convertedXmlElement = {
], ],
}, },
], ],
rootKey: undefined,
}; };
describe("ImportedXmlComponent", () => { describe("ImportedXmlComponent", () => {
@ -63,7 +62,7 @@ describe("ImportedXmlComponent", () => {
it("should transform for xml", () => { it("should transform for xml", () => {
// tslint:disable-next-line: no-object-literal-type-assertion // tslint:disable-next-line: no-object-literal-type-assertion
const converted = importedXmlComponent.prepForXml({ stack: [] } as unknown as IContext); const converted = importedXmlComponent.prepForXml({ stack: [] } as unknown as IContext);
expect(converted).to.deep.equal({ expect(JSON.parse(JSON.stringify(converted))).to.deep.equal({
"w:test": [ "w:test": [
{ {
_attr: { _attr: {
@ -81,14 +80,14 @@ describe("ImportedXmlComponent", () => {
it("should create XmlComponent from xml string", () => { it("should create XmlComponent from xml string", () => {
const converted = ImportedXmlComponent.fromXmlString(xmlString); const converted = ImportedXmlComponent.fromXmlString(xmlString);
expect(converted).to.deep.equal(convertedXmlElement); expect(JSON.parse(JSON.stringify(converted))).to.deep.equal(convertedXmlElement);
}); });
describe("convertToXmlComponent", () => { describe("convertToXmlComponent", () => {
it("should convert to xml component", () => { it("should convert to xml component", () => {
const xmlObj = xml2js(xmlString, { compact: false }) as Element; const xmlObj = xml2js(xmlString, { compact: false }) as Element;
const converted = convertToXmlComponent(xmlObj); const converted = convertToXmlComponent(xmlObj);
expect(converted).to.deep.equal(convertedXmlElement); expect(JSON.parse(JSON.stringify(converted))).to.deep.equal(convertedXmlElement);
}); });
it("should return undefined if xml type is invalid", () => { it("should return undefined if xml type is invalid", () => {