Fix tests. _attr is needed
This commit is contained in:
@ -1,17 +1,18 @@
|
|||||||
// tslint:disable:no-any
|
// tslint:disable:no-any
|
||||||
|
// tslint:disable:variable-name
|
||||||
import { IXmlableObject, XmlComponent } from "./";
|
import { IXmlableObject, XmlComponent } from "./";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Represents imported xml component from xml file.
|
* Represents imported xml component from xml file.
|
||||||
*/
|
*/
|
||||||
export class ImportedXmlComponent extends XmlComponent {
|
export class ImportedXmlComponent extends XmlComponent {
|
||||||
private attr: any;
|
private _attr: any;
|
||||||
|
|
||||||
constructor(rootKey: string, attr?: any) {
|
constructor(rootKey: string, attr?: any) {
|
||||||
super(rootKey);
|
super(rootKey);
|
||||||
|
|
||||||
if (attr) {
|
if (attr) {
|
||||||
this.attr = attr;
|
this._attr = attr;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -43,11 +44,11 @@ export class ImportedXmlComponent extends XmlComponent {
|
|||||||
*/
|
*/
|
||||||
public prepForXml(): IXmlableObject {
|
public prepForXml(): IXmlableObject {
|
||||||
const result = super.prepForXml();
|
const result = super.prepForXml();
|
||||||
if (!!this.attr) {
|
if (!!this._attr) {
|
||||||
if (!Array.isArray(result[this.rootKey])) {
|
if (!Array.isArray(result[this.rootKey])) {
|
||||||
result[this.rootKey] = [result[this.rootKey]];
|
result[this.rootKey] = [result[this.rootKey]];
|
||||||
}
|
}
|
||||||
result[this.rootKey].unshift({ _attr: this.attr });
|
result[this.rootKey].unshift({ _attr: this._attr });
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -61,13 +62,13 @@ export class ImportedXmlComponent extends XmlComponent {
|
|||||||
* Used for the attributes of root element that is being imported.
|
* Used for the attributes of root element that is being imported.
|
||||||
*/
|
*/
|
||||||
export class ImportedRootElementAttributes extends XmlComponent {
|
export class ImportedRootElementAttributes extends XmlComponent {
|
||||||
constructor(private attr: any) {
|
constructor(private _attr: any) {
|
||||||
super("");
|
super("");
|
||||||
}
|
}
|
||||||
|
|
||||||
public prepForXml(): IXmlableObject {
|
public prepForXml(): IXmlableObject {
|
||||||
return {
|
return {
|
||||||
_attr: this.attr,
|
_attr: this._attr,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user