#1507 - Add scale for run
This commit is contained in:
@ -3,7 +3,7 @@ import { Element, xml2js } from "xml-js";
|
||||
|
||||
import { EMPTY_OBJECT } from "@file/xml-components";
|
||||
|
||||
import { convertToXmlComponent, ImportedXmlComponent } from "./imported-xml-component";
|
||||
import { convertToXmlComponent, ImportedRootElementAttributes, ImportedXmlComponent } from "./imported-xml-component";
|
||||
import { IContext } from "./base";
|
||||
|
||||
const xmlString = `
|
||||
@ -90,5 +90,29 @@ describe("ImportedXmlComponent", () => {
|
||||
const converted = convertToXmlComponent(xmlObj);
|
||||
expect(converted).to.deep.equal(convertedXmlElement);
|
||||
});
|
||||
|
||||
it("should return undefined if xml type is invalid", () => {
|
||||
const xmlObj = { type: "invalid" } as Element;
|
||||
const converted = convertToXmlComponent(xmlObj);
|
||||
expect(converted).to.equal(undefined);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
describe("ImportedRootElementAttributes", () => {
|
||||
let attributes: ImportedRootElementAttributes;
|
||||
|
||||
beforeEach(() => {
|
||||
attributes = new ImportedRootElementAttributes({});
|
||||
});
|
||||
|
||||
describe("#prepForXml()", () => {
|
||||
it("should work", () => {
|
||||
// tslint:disable-next-line: no-object-literal-type-assertion
|
||||
const converted = attributes.prepForXml({} as IContext);
|
||||
expect(converted).to.deep.equal({
|
||||
_attr: {},
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -53,6 +53,13 @@ export class NumberValueElement extends XmlComponent {
|
||||
}
|
||||
}
|
||||
|
||||
export class StringEnumValueElement<T extends string> extends XmlComponent {
|
||||
public constructor(name: string, val: T) {
|
||||
super(name);
|
||||
this.root.push(new Attributes({ val }));
|
||||
}
|
||||
}
|
||||
|
||||
// Simple nodes containing text.
|
||||
//
|
||||
// new StringContainer("hello", "world")
|
||||
|
Reference in New Issue
Block a user